From oleg at okmij.org Mon Dec 1 02:04:05 2008 From: oleg at okmij.org (oleg@okmij.org) Date: Mon Dec 1 01:57:55 2008 Subject: [Haskell-cafe] The Knight's Tour: solutions please Message-ID: <20081201070405.54903AB0F@Adric.metnet.fnmoc.navy.mil> It seems the following pure functional (except for the final printout) version of the search has almost the same performance as the Dan Doel's latest version with the unboxed arrays and callCC. For the board of size 40, Dan Doel's version takes 0.047s on my computer; the version below takes 0.048s. For smaller boards, the difference is imperceptible. Interestingly, the file sizes of the compiled executables (ghc -O2, ghc 6.8.2) are similar too: 606093 bytes for Dan Doel's version, and 605938 bytes for the version below. The version below is essentially Dan Doel's earlier version. Since the problem involves only pure search (rather than committed choice), I took the liberty of substituting FBackTrack (efficient MonadPlus) for LogicT. FBackTrack can too be made the instance of LogicT; there has not been any demand for that though. import Data.List import Data.Ord import qualified Data.IntMap as Map import System.Environment import FBackTrack import Control.Monad -- Emulate the 2-dimensional map as a nested 1-dimensional map initmap n = Map.fromList $ (1,Map.singleton 1 1):[ (k,Map.empty) | k <- [2..n] ] notMember (i,j) m = Map.notMember j $ Map.findWithDefault undefined i m insrt (i,j) v m = Map.update (Just . Map.insert j v) i m lkup (i,j) m = Map.findWithDefault undefined j $ Map.findWithDefault undefined i m successors n b = sortWith (length . succs) . succs where sortWith f = map fst . sortBy (comparing snd) . map (\x -> (x, f x)) succs (i,j) = [ (i', j') | (dx,dy) <- [(1,2),(2,1)] , i' <- [i+dx,i-dx] , j' <- [j+dy, j-dy] , i' >= 1, j' >= 1, i' <= n, j' <= n , notMember (i',j') b ] tour n k s b | k > n*n = return b | otherwise = do next <- foldl1 mplus.map return $ successors n b s tour n (k+1) next $ insrt next k b showBoard n b = unlines . map (\i -> unwords . map (\j -> pad $ lkup (i,j) b) $ [1..n]) $ [1..n] where k = length . show $ n*n + 1 pad i = let s = show i in replicate (k-length s) ' ' ++ s main = do (n:_) <- map read `fmap` getArgs let (b:_) = runM Nothing . tour n 2 (1,1) $ initmap n putStrLn $ showBoard n b From emax at chalmers.se Mon Dec 1 02:06:31 2008 From: emax at chalmers.se (Emil Axelsson) Date: Mon Dec 1 02:00:00 2008 Subject: [Haskell-cafe] Combining licences Message-ID: <49338CF7.9040407@chalmers.se> Hello, I know very little about licensing, so I'm hoping to get some advice from you guys. In the next release of Wired, I plan to include an open-source standard cell library (or rather data derived from it). This cell library has a custom license (found at the bottom of http://www.nangate.com/openlibrary). It appears to be very permissive, but it states that the license text "must be included in all copies of the Library, in whole or in part, and all derivative works of the Library". Wired itself is BSD3-licensed. How do I arrange this in the package? Can I still have a BSD3 license for Wired? Where do I put the respective license texts? Any other things I should have in mind? Or perhaps it's better to put the cell library in its own package? I'm a bit reluctant to do this, because it means that Wired will be essentially useless on its own. Thanks, / Emil From lemming at henning-thielemann.de Mon Dec 1 03:48:48 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Dec 1 03:42:18 2008 Subject: [Haskell-cafe] Cabal In-Reply-To: <1228085508.10115.116.camel@localhost> References: <20081129033017.GB31753@sliver.repetae.net> <20081129113039.GA29053@petunia.outback.escape.de> <20081129193152.GA30959@scytale.galois.com> <20081129201651.GA8079@petunia.outback.escape.de> <916b84820811291737j71fe288ct1551242466399787@mail.gmail.com> <49327180.1080707@btinternet.com> <20081130194610.GA3582@scytale.galois.com> <20081130201029.GE3582@scytale.galois.com> <1228085508.10115.116.camel@localhost> Message-ID: On Sun, 30 Nov 2008, Duncan Coutts wrote: > On Sun, 2008-11-30 at 21:14 +0100, Henning Thielemann wrote: >> On Sun, 30 Nov 2008, Don Stewart wrote: >> >>> lemming: >>>> >>>> Maybe you like to add a pointer in cabal-install.cabal/Homepage field to >>>> this page. >>> >>> Good idea. Duncan? >> >> After I finished that article, I also found: >> http://hackage.haskell.org/trac/hackage/wiki/CabalInstall > > I'm trying to work out what the best thing is to do with the Cabal > documentation. Currently it's kind of patchy and spread over about three > sites. There's the http://haskell.org/cabal website, the dev wiki and > trac and the pages on the main Haskell.org wiki. ... and it's divided into cabal and cabal-install documentation. Though, this separation might also be sensible. > I think ideally we'd have all the user documentation on the cabal > website, including the docs for cabal-install. Unless people think > that's a silly idea and we should just put everything on the haskellwiki > system. For me, access to HaskellWiki is the easiest, because I have no access to haskell.org/cabal I think. :-) In general people might like to add personal comments about cabal, which is best done in the wiki. E.g. if you solve a problem you can quickly add that solution to the FAQ. I don't mind having an official "static" site like haskell.org/cabal which points to a "dynamic" haskellwiki/Cabal and vice versa, but I think another page at haskell.org/trac is redundant. From lemming at henning-thielemann.de Mon Dec 1 03:53:44 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Dec 1 03:47:13 2008 Subject: [Haskell-cafe] Combining licences In-Reply-To: <49338CF7.9040407@chalmers.se> References: <49338CF7.9040407@chalmers.se> Message-ID: On Mon, 1 Dec 2008, Emil Axelsson wrote: > Or perhaps it's better to put the cell library in its own package? I'm a bit > reluctant to do this, because it means that Wired will be essentially useless > on its own. It's more the question, whether a Haskell wrapper to the cell library is useful on its own. I assume yes, and thus it sounds like a good idea to make separate package for a cell library wrapper. From emax at chalmers.se Mon Dec 1 04:43:19 2008 From: emax at chalmers.se (Emil Axelsson) Date: Mon Dec 1 04:36:47 2008 Subject: [Haskell-cafe] Combining licences In-Reply-To: References: <49338CF7.9040407@chalmers.se> Message-ID: <4933B1B7.4070502@chalmers.se> Henning Thielemann skrev: > On Mon, 1 Dec 2008, Emil Axelsson wrote: > >> Or perhaps it's better to put the cell library in its own package? I'm >> a bit reluctant to do this, because it means that Wired will be >> essentially useless on its own. > > It's more the question, whether a Haskell wrapper to the cell library is > useful on its own. I assume yes, and thus it sounds like a good idea to > make separate package for a cell library wrapper. Well, not really. It's not a "Haskell wrapper" in the normal sense where you make a Haskell API around some code in another language. A cell library is a bunch of cell models in various formats. For example, a VHDL file gives the logical models, and another file contains tables with timing data. Wired has its own way of modeling cells (a number of classes), and what I've done is to translate the cell library data to Wired's model. So if I make it a separate package, it would have to depend on Wired. Of course, it still makes sense to have cell libraries as separate packages (I don't want to include every future cell lib in Wired). But I would like at least one cell lib to be shipped together with Wired. / Emil From jules at jellybean.co.uk Mon Dec 1 05:10:13 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Dec 1 05:03:41 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <492DC16E.8050606@btinternet.com> References: <492DC16E.8050606@btinternet.com> Message-ID: <4933B805.50007@jellybean.co.uk> Andrew Coppin wrote: > What I *haven't* done yet is read the chapters where they try to claim > that database programming is possible in Haskell. I'll have to do that > at some point. Maybe this is where they reveal the Secret Formula that > makes this stuff actually work properly... but somehow I doubt it. What a ridiculous comment. Are you hoping to provoke people into helping you by sounding more stupid than you are? Database programming is obviously possible in haskell. Many many people are doing it. The documentation may be patchy, the libraries may be hard to install (often the case with free software for databases, for some reason) but that's quite a long way from impossible. Jules From wagner.andrew at gmail.com Mon Dec 1 06:24:11 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Dec 1 06:17:39 2008 Subject: [Haskell-cafe] Re: Binary Trees missing on hackage In-Reply-To: <4933C5D5.2000902@dfki.de> References: <4933C5D5.2000902@dfki.de> Message-ID: The reasons I've always heard for this is that 1.) It's so easy to define a tree and 2.) There are tons of different variations of trees and what you can do with them. Not that I 100% agree, just what I've always heard. On Mon, Dec 1, 2008 at 6:09 AM, Christian Maeder wrote: > Hi, > > I was surprised that I could not find a "classical" binary tree data > structure on hackage, mainly for teaching purposes, like: > > data BinTree a = Nil | Node (BinTree a) a (BinTree a) > > with a couple of utility functions and instances (i.e. in-order traversal). > > Surely, one may argue, that such a tree can always be defined on the fly > when needed, but nobody would argue so for lists or tuples. (Although > I've rarely seen someone redefining lists, it is quite common to > introduce user-defined products or enumerations.) > > There are rose trees in Data.Tree and many other variants of trees are > conceivable, ie. > > data Boom a = Leaf a | Node (Boom a) (Boom a) > > or a kind of combination: > > data BinLeafTree a b = > Leaf b > | Node (BinLeafTree a b) a (BinLeafTree a b) > > I don't know, why I find the above BinTree most important. I'm not even > sure if such a tree could be re-used for Search- or AVL-trees that need > strict fields with redundant size or height counters for efficiency > reasons. > > In any case I would find such a data type at least as useful as > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OneTuple > > Who would supply and maintain such a package? Or did I simply not search > hard enough? > > Cheers Christian > > P.S. I took the (non-empty) "Boom" from the Boom-Hierarchy described in > "An Exploration of the Bird-Meertens Formalism" by Roland Backhouse > 1988, Groningen > > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://www.haskell.org/mailman/listinfo/libraries > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081201/8e976edb/attachment.htm From bjorn at bringert.net Mon Dec 1 08:19:49 2008 From: bjorn at bringert.net (Bjorn Bringert) Date: Mon Dec 1 08:13:18 2008 Subject: [Haskell-cafe] Haskell, successing crossplatform API standart In-Reply-To: <5CDE013B-1F09-48A9-8946-93959E911E52@gmail.com> References: <20742743.post@talk.nabble.com> <5CDE013B-1F09-48A9-8946-93959E911E52@gmail.com> Message-ID: On Sun, Nov 30, 2008 at 17:51, Sterling Clover wrote: > Haxr provides a basic implementation of the XML-RPC protocol, and while it > looks like it doesn' t build on 6.10 at the moment, getting it to build > shouldn't be a problem, and although it doesn't appear to be under active > development, it does seem to be getting maintenance uploads. [1] HaXR should build with GHC 6.10 now, thanks for the prod. > These days, however, web services seem to be moving towards a RESTful model > with a JSON layer and there are plenty of JSON libraries on hackage, which > you could just throw over the fastCGI bindings. Alternately you could try > JSON over one of the really lightweight haskell web servers, such as shed > [2] or lucu [3]. If you go the latter route, I'd love to hear how it went. I agree with this. I would only use XML-RPC to talk to legacy applications. > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haxr > [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/httpd-shed > [3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Lucu /Bj?rn From marlowsd at gmail.com Mon Dec 1 08:22:34 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Dec 1 08:16:08 2008 Subject: [Haskell-cafe] Re: catting to cat gets stuck at > 135K In-Reply-To: <20081128182213.14275276C41@mail.avvanta.com> References: <42784f260811101329o6fde82f5x1a9636e4cd8ba948@mail.gmail.com> <5558E5DB-A741-4FF9-8596-FC70BC9BF835@ece.cmu.edu> <42784f260811101604q595bfaeam1c07d1a918fca7cd@mail.gmail.com> <492EA5C9.7050803@gmail.com> <00034B2E-5008-4489-855C-D5AD524509FB@ece.cmu.edu> <1227881311.10115.21.camel@localhost> <20081128182213.14275276C41@mail.avvanta.com> Message-ID: <4933E51A.4070201@gmail.com> Donn Cave wrote: > Quoth Duncan Coutts : > | On Thu, 2008-11-27 at 11:38 -0500, Brandon S. Allbery KF8NH wrote: > | > |> The way this is usually handled in the non-threaded case is to either > |> use SIGCHLD or non-blocking waitpid() so that "green" threads can > |> continue running. I'm a little surprised this wasn't done. > | > | Yes, we've discussed this in detail a few months back. We even have a > | partial implementation. However it stalled on needing a better signals > | API which we have not managed to get through the standardisation > | process. > | > | Unfortunately there is no non-blocking (non-polling) waitpid() and the > | global (process-scope) nature of signals is a pain. > > SIGCHLD can be a pain in its own unusual way. Once you have a SIGCHLD > handler, process exits will interrupt "long" I/O, so every such read(), > recv() or whatever must now check for EINTR and restart. Even though > the authors of GHC go to great lengths to convert all I/O to non-blocking > anyway, this will still apply to external library functions that are > beyond GHC's reach. So it's a strategy I would use only if I were kind > of desperate. We already have this issue since GHC's runtime uses a SIGVTALRM timer signal for context switching and profiling. Indeed, it did cause trouble with the editline library which doesn't test for EINTR in one or two places, and we had to work around it by temporarily disabling the timer. Still, it's standard practice to test for EINTR and all library code should do it. Cheers, Simon From wagner.andrew at gmail.com Mon Dec 1 08:28:27 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Dec 1 08:21:56 2008 Subject: [Haskell-cafe] Re: Binary Trees missing on hackage In-Reply-To: References: <4933C5D5.2000902@dfki.de> Message-ID: Hm, I've been thinking about this this morning as I've gone about my commute. I could indeed imagine a class like the following that had multiple implementations like you're talking about: class Tree t where drawTree :: t String -> String flatten :: t a -> [a] etc. (see http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html) I think that for this to be valuable, though, we would need to show that there are functions which can take a generic Tree t and do something useful with it. Still, I suspect there's something there. Maybe I'll take a stab at it this week sometime. On Mon, Dec 1, 2008 at 6:24 AM, Andrew Wagner wrote: > The reasons I've always heard for this is that 1.) It's so easy to define a > tree and 2.) There are tons of different variations of trees and what you > can do with them. Not that I 100% agree, just what I've always heard. > > On Mon, Dec 1, 2008 at 6:09 AM, Christian Maeder > wrote: > >> Hi, >> >> I was surprised that I could not find a "classical" binary tree data >> structure on hackage, mainly for teaching purposes, like: >> >> data BinTree a = Nil | Node (BinTree a) a (BinTree a) >> >> with a couple of utility functions and instances (i.e. in-order >> traversal). >> >> Surely, one may argue, that such a tree can always be defined on the fly >> when needed, but nobody would argue so for lists or tuples. (Although >> I've rarely seen someone redefining lists, it is quite common to >> introduce user-defined products or enumerations.) >> >> There are rose trees in Data.Tree and many other variants of trees are >> conceivable, ie. >> >> data Boom a = Leaf a | Node (Boom a) (Boom a) >> >> or a kind of combination: >> >> data BinLeafTree a b = >> Leaf b >> | Node (BinLeafTree a b) a (BinLeafTree a b) >> >> I don't know, why I find the above BinTree most important. I'm not even >> sure if such a tree could be re-used for Search- or AVL-trees that need >> strict fields with redundant size or height counters for efficiency >> reasons. >> >> In any case I would find such a data type at least as useful as >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OneTuple >> >> Who would supply and maintain such a package? Or did I simply not search >> hard enough? >> >> Cheers Christian >> >> P.S. I took the (non-empty) "Boom" from the Boom-Hierarchy described in >> "An Exploration of the Bird-Meertens Formalism" by Roland Backhouse >> 1988, Groningen >> >> _______________________________________________ >> Libraries mailing list >> Libraries@haskell.org >> http://www.haskell.org/mailman/listinfo/libraries >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081201/95573ebe/attachment.htm From marlowsd at gmail.com Mon Dec 1 08:36:16 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Dec 1 08:30:10 2008 Subject: [Haskell-cafe] Re: getLine and ^C on Windows In-Reply-To: References: <670e468e0811122343p7531e32ub8618f127f57b42e@mail.gmail.com> <6cf91caa0811130123t2d9084cma01c20e87a536e57@mail.gmail.com> Message-ID: <4933E850.6000904@gmail.com> Mitchell, Neil wrote: > Hi > > I have the same experience with Windows XP and getContents, so I think > it's the entire IO layer on Windows, rather than just getLine on Vista. > This is being tracked here > http://hackage.haskell.org/trac/ghc/ticket/2758 Which is now fixed, FYI. 6.10.2 will have the fix. Cheers, Simon From marlowsd at gmail.com Mon Dec 1 08:41:32 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Dec 1 08:35:04 2008 Subject: [Haskell-cafe] Re: Problem with directory-1.0.0.0 In-Reply-To: <200811132208.20012.bartek@sudety.it> References: <200811132208.20012.bartek@sudety.it> Message-ID: <4933E98C.3030701@gmail.com> Bartosz W?jcik wrote: > Hi Folks, > > I'm facing problem after I've reinstalled directory-1.0.0.0 (setup > configure/build/install). Since then I cannot complie anything that needs > this library. It fails with following messages: > > Preprocessing library haddock-2.4.0... > Preprocessing executables for haddock-2.4.0... > Building haddock-2.4.0... > /usr/bin/ar: creating dist/build/libHShaddock-2.4.0.a > Linking dist/build/haddock/haddock ... > /usr/local/lib/ghc-6.8.2/libHSghc.a(Coverage.o): In function `scXR_info': > (.text+0x17b7c): undefined reference to > `directoryzm1zi0zi0zi0_SystemziDirectory_lvl29_closure' > /usr/local/lib/ghc-6.8.2/libHSghc.a(Coverage.o): In function `s8xU_info': > (.text+0x1792c): undefined reference to > `directoryzm1zi0zi0zi0_SystemziDirectory_a43_info' > /usr/local/lib/ghc-6.8.2/libHSghc.a(Coverage.o): In function `r7aC_closure': > (.data+0xd18): undefined reference to > `directoryzm1zi0zi0zi0_SystemziDirectory_a43_closure' > collect2: ld returned 1 exit status > > Situation is following: > Old directory-1.0.0.0 resides > in /usr/local/lib/ghc-6.8.2/lib/directory-1.0.0.0. > New one in /usr/local/lib/directory-1.0.0.0. > > Why new one doesn't work? > How to force linker to use old one? What happened here is that you recompiled directory without recompiling the things that depend on it (e.g. GHC). This is a problem because compiled Haskell libraries don't have a fixed ABI: if you recompile the library, you get a different result, and all the compiled clients of the library must be recompiled. For libraries that GHC depends on, this is a problem, because it's usually not practical to recompile GHC. You can usually install a newer version of these libraries without conflicting with the old version, though. We do think this is something that needs to be fixed in a future version of GHC (hopefully 6.12). Cheers, Simon From Christian.Maeder at dfki.de Mon Dec 1 09:39:18 2008 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Mon Dec 1 09:32:47 2008 Subject: [Haskell-cafe] Re: Binary Trees missing on hackage In-Reply-To: References: <4933C5D5.2000902@dfki.de> Message-ID: <4933F716.2000806@dfki.de> I find classes for sequences, collections (edison) and graphs (fgl) and your proposed trees a bit awkward. I'ld like to see the actual data types first. Like for lists I can imagine a whole bunch of useful functions for BinTree (below) that are already implemented multiple times for user defined binary trees (in other libraries). Cheers Christian Andrew Wagner wrote: > Hm, I've been thinking about this this morning as I've gone about my > commute. I could indeed imagine a class like the following that had > multiple implementations like you're talking about: > > class Tree t where > drawTree :: t String -> String > flatten :: t a -> [a] > etc. > (see http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html) > > > I think that for this to be valuable, though, we would need to show that > there are functions which can take a generic Tree t and do something > useful with it. Still, I suspect there's something there. Maybe I'll > take a stab at it this week sometime. > > On Mon, Dec 1, 2008 at 6:24 AM, Andrew Wagner > wrote: > > The reasons I've always heard for this is that 1.) It's so easy to > define a tree and 2.) There are tons of different variations of > trees and what you can do with them. Not that I 100% agree, just > what I've always heard. > > On Mon, Dec 1, 2008 at 6:09 AM, Christian Maeder > > wrote: > > Hi, > > I was surprised that I could not find a "classical" binary tree data > structure on hackage, mainly for teaching purposes, like: > > data BinTree a = Nil | Node (BinTree a) a (BinTree a) > > with a couple of utility functions and instances (i.e. in-order > traversal). > > Surely, one may argue, that such a tree can always be defined on > the fly > when needed, but nobody would argue so for lists or tuples. > (Although > I've rarely seen someone redefining lists, it is quite common to > introduce user-defined products or enumerations.) > > There are rose trees in Data.Tree and many other variants of > trees are > conceivable, ie. > > data Boom a = Leaf a | Node (Boom a) (Boom a) > > or a kind of combination: > > data BinLeafTree a b = > Leaf b > | Node (BinLeafTree a b) a (BinLeafTree a b) > > I don't know, why I find the above BinTree most important. I'm > not even > sure if such a tree could be re-used for Search- or AVL-trees > that need > strict fields with redundant size or height counters for > efficiency reasons. > > In any case I would find such a data type at least as useful as > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OneTuple > > Who would supply and maintain such a package? Or did I simply > not search > hard enough? > > Cheers Christian > > P.S. I took the (non-empty) "Boom" from the Boom-Hierarchy > described in > "An Exploration of the Bird-Meertens Formalism" by Roland Backhouse > 1988, Groningen > > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://www.haskell.org/mailman/listinfo/libraries > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ndmitchell at gmail.com Mon Dec 1 10:08:54 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Dec 1 10:02:22 2008 Subject: [Haskell-cafe] workarounds for Codec.Compression.Zlib errors in darcs In-Reply-To: <20081127172008.GA20810@matrix.chaos.earth.li> References: <20081126143832.GC15463@brighton.ac.uk> <1227738501.19577.42.camel@localhost> <20081127172008.GA20810@matrix.chaos.earth.li> Message-ID: <404396ef0812010708w3440f2a1m68bc37b4aacdd224@mail.gmail.com> > While that's true, Haskell also makes it easy to make the same sort of > error with IO (or any other Monad) values, whether created with the FFI > or not. If you say > > f = do x > y > z > > and y has type IO CInt then you won't get an error (and I don't think > you can even ask for a warning with the current implementations). > > Should we have > (>>) :: (Monad m) => m () -> m a -> m a > and force you to write > _ <- y It's intersting to note that F# follows exactly your proposal. If x has a return type other than () then you do: y |> ignore where ignore :: a -> (), and |> = flip ($) In practice, I found this quite reasonable to use. You also eliminate "errors" such as: do mapM deleteFile files ; return 1 Where mapM requires more memory than the equivalent mapM_ Thanks Neil From cppljevans at suddenlink.net Mon Dec 1 10:43:22 2008 From: cppljevans at suddenlink.net (Larry Evans) Date: Mon Dec 1 10:30:46 2008 Subject: [Haskell-cafe] Re: howto tuple fold to do n-ary cross product? In-Reply-To: References: <7ca3f0160811231152o19234e16g9f29677029306a@mail.gmail.com> <7ca3f0160811300930q1e373076v1c227cbd9cc42851@mail.gmail.com> <4932D5A2.6070306@suddenlink.net> <7ca3f0160811301027l650c1faewe0a2fb94206af1d9@mail.gmail.com> Message-ID: On 11/30/08 12:49, Larry Evans wrote: [snip] > > You'll see Domains can be an mpl::vector of any > length. The cross_nproduct_view_test.cpp tests > with a 3 element Domains: > > typedef > mpl::vector > < mpl::range_c > , mpl::range_c > , mpl::range_c > > > domains; OOPS. That's in another test driver. The one in the cross_nproduct_view_test.cpp has: typedef range_c seq0; typedef range_c seq1; typedef range_c seq2; typedef range_c seq3; typedef list < seq0 , seq1 , seq2 , seq3 > domains; The range_c template instance: http://www.boost.org/doc/libs/1_37_0/libs/mpl/doc/refmanual/range-c.html produces a type sequence of length 2. So mpl::list is a sequence of sequences similar to haskell's [[a]] except that it's a sequence of a sequences of types instead of a sequence of sequences of values. > > The cross_nproduct_view template and test driver > are found in the cross_nproduct_view.zip file here: > > http://preview.tinyurl.com/5ar9g4 From jgoerzen at complete.org Mon Dec 1 11:07:55 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Dec 1 11:01:30 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <20081129192715.GB30881@scytale.galois.com> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> Message-ID: <49340BDB.5050604@complete.org> Don Stewart wrote: > Very curious. Did you file a bug report with the maintainers of the 30+ > database packages on hackage? > > Or did you not have the underlying database drivers installed? > > Did you make any attempt to contact the authors to determine the cause > of your problem? Incidentally, with my HDBC maintainer hat on, I can state: 1) That I have no Windows development machines myself; 2) That Windows people are using HDBC and HDBC-ODBC; 3) I actively try to maintain all of my packages in a cross-platform-friendly manner (except those that are really tied to one platform, such as HSH) 4) Windows users actively send me patches if something breaks, and these are readily applied. I don't think this state of affairs is unique in the Haskell world. Some people use Linux, Mac, or Windows as their main development box, but pretty much everybody tries to support all platforms. Incidentally, Andrew Coppin (CCd on this thread already) is one of those that has sent me patches. -- John From colin at colina.demon.co.uk Mon Dec 1 12:32:08 2008 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Mon Dec 1 12:25:41 2008 Subject: [Haskell-cafe] Parallel alpha-beta search Message-ID: Has anyone ever attempted this in Haskell? If so, what sort of speed-up have you had (with which algorithm)? -- Colin Adams Preston Lancashire From bertram.felgenhauer at googlemail.com Mon Dec 1 13:39:13 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Mon Dec 1 13:32:48 2008 Subject: [Haskell-cafe] The Knight's Tour: solutions please In-Reply-To: <20081130213102.GB3881@scytale.galois.com> References: <20081130213102.GB3881@scytale.galois.com> Message-ID: <20081201183913.GA13054@zombie.inf.tu-dresden.de> Don Stewart wrote: > Lee Pike forwarded the following: > > "Solving the Knight's Tour Puzzle In 60 Lines of Python" > > http://developers.slashdot.org/article.pl?sid=08/11/30/1722203 > > Seems that perhaps (someone expert in) Haskell could do even better? > Maybe even parallelize the problem? :) As one of the posters there points out, for n=100 the program doesn't actually backtrack if the 'loneliest neighbour' heuristic is used. Do any of our programs finish quickly for n=99? The Python one doesn't. Bertram From paul.chiusano at gmail.com Mon Dec 1 16:11:06 2008 From: paul.chiusano at gmail.com (Paul Chiusano) Date: Mon Dec 1 16:04:37 2008 Subject: [Haskell-cafe] Scala job in Boston writing quantitative finance software Message-ID: Hi folks, The company I work for, ClariFI (http://clarifi.com/), is looking to hire developers with a strong background in functional programming to do a mixture of Scala and Java programming. It's fine if you don't happen to know Scala but are strong in Haskell - we are looking for people who really "get" FP and who we could turn loose designing and implementing clean, functional code in Scala once up to speed with the language. You'd also work on extending existing Scala modules and integrating the library code you write with application code written in Java. For more info, check out our official job posting: http://www.clarifi.com/About-ClariFI-Careers.php#SoftwareEngineer Some background on us: ClariFI is a small company (about 15 developers) that specializes in software for quantitative investment management. Our chief product, ModelStation, is used by portfolio managers for handling all stages of the quant process: building and backtesting of factors, portfolio optimization, simulation of trading strategies, performance and risk attribution, overall data management (including organizing huge amounts of time series data pulled from a diverse set of raw sources), and lots more. We don't expect you to have a background in finance but you should be willing and able to learn a lot once you start. This position is in our Boston office, so you must live or be willing to relocate here in order to be considered. If you're interested, send an email to myself or my boss, Scott McFarland (smcfarland@clarifi.com), along with your resume. Also, feel free to contact either of us if you just have questions about the position. Cheers, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081201/e6bc2592/attachment-0001.htm From diegoeche at gmail.com Mon Dec 1 16:48:40 2008 From: diegoeche at gmail.com (Diego Echeverri) Date: Mon Dec 1 16:42:52 2008 Subject: [Haskell-cafe] Re: The Knight's Tour: solutions please Message-ID: <72044db40812011348t16c7fe45sf1126adf52e22f0e@mail.gmail.com> >>I've created a wiki page, >>http://haskell.org/haskellwiki/The_Knights_Tour >>I note the LogicT version is the shortest so far. >>-- Don Probably noob question. I was looking into the first solution in the page and tried to replace sortOn f = map snd . sortBy (comparing fst) . map (f &&& id) for sortOn' f = sortBy (comparing fst) The first one was much faster? Why? Thanks! Diego From andrewcoppin at btinternet.com Mon Dec 1 16:59:24 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Dec 1 16:52:43 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <49340BDB.5050604@complete.org> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> Message-ID: <49345E3C.6090002@btinternet.com> John Goerzen wrote: > Don Stewart wrote: > > >> Very curious. Did you file a bug report with the maintainers of the 30+ >> database packages on hackage? >> >> Or did you not have the underlying database drivers installed? >> >> Did you make any attempt to contact the authors to determine the cause >> of your problem? >> > > Incidentally, with my HDBC maintainer hat on, I can state: > > 1) That I have no Windows development machines myself; > > 2) That Windows people are using HDBC and HDBC-ODBC; > > 3) I actively try to maintain all of my packages in a > cross-platform-friendly manner (except those that are really tied to one > platform, such as HSH) > > 4) Windows users actively send me patches if something breaks, and these > are readily applied. > > I don't think this state of affairs is unique in the Haskell world. > Some people use Linux, Mac, or Windows as their main development box, > but pretty much everybody tries to support all platforms. > > Incidentally, Andrew Coppin (CCd on this thread already) is one of those > that has sent me patches. > OK, now I'm puzzled. I don't remember that! :-} I recall _trying_ to get a few of the database packages to build (I cannot remember which one(s) now - there's so many). In fact, IIRC, I even got the "base" package to build, but the driver for my database wouldn't build. (I forget why exactly.) In my experience, almost *everything* on Hackage consistently fails to build on Windows, so I think by this point I'd more or less given up even trying to make things build for me. In short, I didn't follow this one very far... At least, that's how I remember it. I guess this is where somebody digs up some thread on cafe from 3 years ago or something and proves me wrong. :-} In other news... why the hell does my ISP never deliver any emails to cafe originating from Don? They show up in Gmane, but not my inbox... how frustrating! (I'd reply to his other email, but I can't because it's not in my inbox.) From duncan.coutts at worc.ox.ac.uk Mon Dec 1 17:02:47 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 1 16:56:17 2008 Subject: [Haskell-cafe] Re: The Knight's Tour: solutions please In-Reply-To: <72044db40812011348t16c7fe45sf1126adf52e22f0e@mail.gmail.com> References: <72044db40812011348t16c7fe45sf1126adf52e22f0e@mail.gmail.com> Message-ID: <1228168967.10115.147.camel@localhost> On Mon, 2008-12-01 at 22:48 +0100, Diego Echeverri wrote: > >>I've created a wiki page, > >>http://haskell.org/haskellwiki/The_Knights_Tour > >>I note the LogicT version is the shortest so far. > >>-- Don > > Probably noob question. I was looking into the first solution in the > page and tried to replace > > sortOn f = map snd . sortBy (comparing fst) . map (f &&& id) > for > sortOn' f = sortBy (comparing fst) Presumably you mean: sortOn' f = sortBy (comparing (f . fst)) > The first one was much faster? Why? Caching. It caches all the calls to f. So f gets called once per-element in the input list rather than every time the sort needs to do a comparison. The number of comparisons sort does is proportional to n * log n. So that's a log factor more calls of f. Presumably f is reasonably expensive in this case, enough to offset the extra book-keeping needed to cache all the calls. Duncan From ganesh at earth.li Mon Dec 1 17:14:43 2008 From: ganesh at earth.li (Ganesh Sittampalam) Date: Mon Dec 1 17:08:11 2008 Subject: [Haskell-cafe] manipulating predicate formulae In-Reply-To: <404396ef0811301406i38ea81c6pd325f2850f2fef5d@mail.gmail.com> References: <404396ef0811301406i38ea81c6pd325f2850f2fef5d@mail.gmail.com> Message-ID: On Sun, 30 Nov 2008, Neil Mitchell wrote: > http://www.cs.york.ac.uk/fp/darcs/proposition/ > > Unreleased, but might be of interest. It simplifies propositional > formulae, and can do so using algebraic laws, custom simplifications > or BDDs. I don't really use this library, so if it is of interest to > you, its all yours :-) Thanks, but I don't think a propositional library is a good starting point for a predicate library - the problems are too different. Sadly my predicates are over infinite domains, otherwise BDDs would have been really nice :-( Cheers, Ganesh From jgm at berkeley.edu Mon Dec 1 17:32:07 2008 From: jgm at berkeley.edu (John MacFarlane) Date: Mon Dec 1 17:25:35 2008 Subject: [Haskell-cafe] Re: '#' in literate haskell In-Reply-To: <20081130085726.GA4207@zombie.inf.tu-dresden.de> References: <20081130030733.GA3849@berkeley.edu> <20081130085726.GA4207@zombie.inf.tu-dresden.de> Message-ID: <20081201223207.GA27132@berkeley.edu> +++ Bertram Felgenhauer [Nov 30 08 09:57 ]: > John MacFarlane wrote: > > Can anyone explain why ghc does not treat the following > > as a valid literate haskell program? > > > > --------- test.lhs ---- > > # This is a test > > > > > foo = reverse . words > > > > ------------------------ > > I believe this is an artifact of ghc trying to parse cpp style line > number information: > > >>> foo.lhs >>> > # 123 "foo.foo" > > > t = <> > <<< > > will print this error: > foo.foo:124:6: parse error on input `<>' Thanks! Mystery solved. John From jgoerzen at complete.org Mon Dec 1 17:51:02 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Dec 1 17:44:30 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <49345E3C.6090002@btinternet.com> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> Message-ID: <20081201225102.GA6243@hustlerturf.com> On Mon, Dec 01, 2008 at 09:59:24PM +0000, Andrew Coppin wrote: >> I don't think this state of affairs is unique in the Haskell world. >> Some people use Linux, Mac, or Windows as their main development box, >> but pretty much everybody tries to support all platforms. >> >> Incidentally, Andrew Coppin (CCd on this thread already) is one of those >> that has sent me patches. >> > > OK, now I'm puzzled. I don't remember that! :-} OK, I went back and looked at my Git logs and you're right. Wrong Andrew. Sorry. > I recall _trying_ to get a few of the database packages to build (I > cannot remember which one(s) now - there's so many). In fact, IIRC, I > even got the "base" package to build, but the driver for my database > wouldn't build. (I forget why exactly.) In my experience, almost > *everything* on Hackage consistently fails to build on Windows, so I > think by this point I'd more or less given up even trying to make things > build for me. In short, I didn't follow this one very far... At least, > that's how I remember it. I guess this is where somebody digs up some > thread on cafe from 3 years ago or something and proves me > wrong. :-} I would welcome bug reports and, even better, patches for this stuff. But I was pretty sure that HDBC and HDBC-ODBC in particular are working on Windows. -- John From dan.doel at gmail.com Mon Dec 1 18:01:08 2008 From: dan.doel at gmail.com (Dan Doel) Date: Mon Dec 1 17:54:41 2008 Subject: [Haskell-cafe] The Knight's Tour: solutions please In-Reply-To: <20081201183913.GA13054@zombie.inf.tu-dresden.de> References: <20081130213102.GB3881@scytale.galois.com> <20081201183913.GA13054@zombie.inf.tu-dresden.de> Message-ID: <200812011801.09705.dan.doel@gmail.com> On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote: > As one of the posters there points out, for n=100 the program doesn't > actually backtrack if the 'loneliest neighbour' heuristic is used. Do any > of our programs finish quickly for n=99? The Python one doesn't. Nothing I tried finished. Do you have any figures on how much backtracking needs to be done to find a solution for n=99 (there is a solution, right?)? I tweaked the continuation version to print k when it backtracks, and it continuously spit out numbers around 9790. I get the feeling it doesn't matter how fast your backtracking infrastructure is in this case as long as you use the same general algorithm. On a long shot, I even tried using Logic's alternate bind based on fair choice, but that didn't seem to be any better. -- Dan From 6c5l7n at googlemail.com Mon Dec 1 18:11:44 2008 From: 6c5l7n at googlemail.com (Georgel Calin) Date: Mon Dec 1 18:05:11 2008 Subject: [Haskell-cafe] Can anybody give me some advice on this? Message-ID: <8c15bc480812011511l7203d055s4566eaa17e488ebf@mail.gmail.com> Hello everybody, I have a piece of code that gives me headaches for some time now. Simply put, I would like to know which is the best way to overpass a "Couldn't match expected type * against inferred type *"-error and an "Occurs check: cannot construct the infinite type:"-error in the following situation: {-# OPTIONS -fglasgow-exts #-} > module Simple where > import Text.ParserCombinators.Parsec > > data HData a = O | C a deriving (Eq,Ord,Show) > data IN l = IN Int (HData l) deriving (Eq,Ord,Show) > data CH l = CH Char (HData l) deriving (Eq,Ord,Show) > -- data type is well-defined: > sample = C(IN 0 (C(CH 'a' (C(IN 1 (C(CH 'b' (C(IN 2 O))))))))) > > embeddedParser types = do string "end"; spaces; return O > {- > <|> do let h = head types > let t = tail types > case h of > 1 -> do aux <- pInt > rest <- embeddedParser $t++[h] > return $ C (IN aux rest) > 2 -> do aux <- pCh > rest <- embeddedParser $t++[h] > return $ C (CH aux rest) > _ -> error "unallowed type" > -} > pInt = do n <- fmap read $ many1 digit; return $ fromInteger n > pCh = do c <- letter; return $ c > simple = embeddedParser [1,2] > > -- the above result from sample I would like to get by running > -- parseTest simple "0a1b2end" > The way I see it, the defined datatype works but I am a bit clueless about how to modify the parser to accept things of the type (e.g.): HData (IN (CH (IN (CH (IN a))))) (and in general of any finite type embedded like this). Thanks in advance for your help, George -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/4ee7b424/attachment.htm From mailing_list at istitutocolli.org Mon Dec 1 19:39:25 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Mon Dec 1 19:32:58 2008 Subject: [Haskell-cafe] global variables for foreign C functions Message-ID: <20081202003924.GC21677@Andrea.Nowhere.net> Hello, I'm writing the bindings to a C library which uses, in some functions, global variables. To make it clearer, those functions need a global variable to be defined. A C program using my_function, one of the library functions, would look like: char progname[] = "a_program_name"; int main( int argc, char *argv[] ) { param p; my_function ( &p ) etc. I've been searching the ML, the wiki, the net, etc. without finding some examples on how such things are dealt with in Haskell - is it possible, BTW? If I import those functions without defining the global variable I get a linker error: /usr/lib/mylib.a(cfile.o): In function `my_function': cfile.c:(.text+0x510): undefined reference to `progname' I hope the issue is clear. Any help would be greatly appreciated. Andrea From qdunkan at gmail.com Mon Dec 1 19:55:14 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Mon Dec 1 19:48:39 2008 Subject: [Haskell-cafe] global variables for foreign C functions In-Reply-To: <20081202003924.GC21677@Andrea.Nowhere.net> References: <20081202003924.GC21677@Andrea.Nowhere.net> Message-ID: <2518b95d0812011655w2585995ega1aebbdc6e0e1cde@mail.gmail.com> On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato wrote: > Hello, > > I'm writing the bindings to a C library which uses, in some functions, > global variables. > > To make it clearer, those functions need a global variable to be > defined. A C program using my_function, one of the library functions, > would look like: I don't think you can use the FFI to declare symbols for C. One not-so-pretty but effective way to do it is create a stub.c with the variables declared along with setting functions, then bind those functions like any other. From judah.jacobson at gmail.com Mon Dec 1 20:30:33 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Mon Dec 1 20:23:59 2008 Subject: [Haskell-cafe] global variables for foreign C functions In-Reply-To: <2518b95d0812011655w2585995ega1aebbdc6e0e1cde@mail.gmail.com> References: <20081202003924.GC21677@Andrea.Nowhere.net> <2518b95d0812011655w2585995ega1aebbdc6e0e1cde@mail.gmail.com> Message-ID: <6d74b0d20812011730x212fab95oadeac0ec756015bb@mail.gmail.com> On Mon, Dec 1, 2008 at 4:55 PM, Evan Laforge wrote: > On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato > wrote: >> Hello, >> >> I'm writing the bindings to a C library which uses, in some functions, >> global variables. >> >> To make it clearer, those functions need a global variable to be >> defined. A C program using my_function, one of the library functions, >> would look like: > > I don't think you can use the FFI to declare symbols for C. One > not-so-pretty but effective way to do it is create a stub.c with the > variables declared along with setting functions, then bind those > functions like any other. You can limit the size of that stub file using: foreign import ccall "&progname" progname :: Ptr (Ptr CChar) which lets you access that global variable and write the getters/setters in Haskell rather than C. -Judah From john at repetae.net Mon Dec 1 20:38:49 2008 From: john at repetae.net (John Meacham) Date: Mon Dec 1 20:32:15 2008 Subject: [Haskell-cafe] global variables for foreign C functions In-Reply-To: <2518b95d0812011655w2585995ega1aebbdc6e0e1cde@mail.gmail.com> References: <20081202003924.GC21677@Andrea.Nowhere.net> <2518b95d0812011655w2585995ega1aebbdc6e0e1cde@mail.gmail.com> Message-ID: <20081202013849.GA18561@sliver.repetae.net> On Mon, Dec 01, 2008 at 04:55:14PM -0800, Evan Laforge wrote: > On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato > wrote: > > Hello, > > > > I'm writing the bindings to a C library which uses, in some functions, > > global variables. > > > > To make it clearer, those functions need a global variable to be > > defined. A C program using my_function, one of the library functions, > > would look like: > > I don't think you can use the FFI to declare symbols for C. One > not-so-pretty but effective way to do it is create a stub.c with the > variables declared along with setting functions, then bind those > functions like any other. Yes, it is unfortunate this is the case. my ForeignData proposal was meant to address this: http://hackage.haskell.org/trac/haskell-prime/wiki/ForeignData I am not entirely sure about the proposal as described, but I think something like it should be done. John -- John Meacham - ?repetae.net?john? From ryani.spam at gmail.com Mon Dec 1 21:08:27 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Dec 1 21:01:54 2008 Subject: [Haskell-cafe] Can anybody give me some advice on this? In-Reply-To: <8c15bc480812011511l7203d055s4566eaa17e488ebf@mail.gmail.com> References: <8c15bc480812011511l7203d055s4566eaa17e488ebf@mail.gmail.com> Message-ID: <2f9b2d30812011808j4c10d3e7s994ba3a2ceeb6cda@mail.gmail.com> The problem is this: what is the type of "embeddedParser"? Unless you can answer that question, you're not going to be able to write it. In particular, its *type* depends on the *value* of its argument; the type of embeddedParser [1,2] is different from the type of embeddedParser [1,1,2]. This isn't possible in Haskell; you need a language with an even more exotic type system (Agda, for example) to encode this dependency. Google "dependent types" for more information. You can encode something similar using existentials: data Sealed p = forall a. Sealed (p a) type ParseResult = Sealed HData ... case h of 1 -> do aux <- pInt Sealed rest <- embeddedParser (t ++ [h]) return (Sealed (C (In aux rest))) and a similar transformation on the (2) case and the "end" case; this makes the type of embeddedParser into Parser ParseResult. What you are doing here is saying that the result of a parse is an HData a for *some* a, but you aren't saying which one. You extract the HData from the existential when running the sub parser, then stuff it back into another existential. But you can't extract the type out of the existential ever; it is lost. In particular you can't prove to the compiler that the type matches that of the [1,2] input and get back to the IN and CH values. And you can't return a value that has been extracted out, you can only stuff it back into another existential container or consume it in some other way! A better option is to use a type that matches what you expect to parse, or just use Data.Dynamic if you want multiple types. You aren't going to get any benefit from "HData a" without a lot more type-level work! Also, for your type list, it'd be much more efficient to use (cycle types) to construct an infinite list (in finite space!) rather than keep appending the head back onto the tail. 2008/12/1 Georgel Calin <6c5l7n@googlemail.com>: > Hello everybody, > > I have a piece of code that gives me headaches for some time now. > > Simply put, I would like to know which is the best way to overpass a > "Couldn't match expected type * against inferred type *"-error and an > "Occurs check: cannot construct the infinite type:"-error in the following > situation: > >> {-# OPTIONS -fglasgow-exts #-} >> module Simple where >> import Text.ParserCombinators.Parsec >> >> data HData a = O | C a deriving (Eq,Ord,Show) >> data IN l = IN Int (HData l) deriving (Eq,Ord,Show) >> data CH l = CH Char (HData l) deriving (Eq,Ord,Show) >> -- data type is well-defined: >> sample = C(IN 0 (C(CH 'a' (C(IN 1 (C(CH 'b' (C(IN 2 O))))))))) >> >> embeddedParser types = do string "end"; spaces; return O >> {- >> <|> do let h = head types >> let t = tail types >> case h of >> 1 -> do aux <- pInt >> rest <- embeddedParser $t++[h] >> return $ C (IN aux rest) >> 2 -> do aux <- pCh >> rest <- embeddedParser $t++[h] >> return $ C (CH aux rest) >> _ -> error "unallowed type" >> -} >> pInt = do n <- fmap read $ many1 digit; return $ fromInteger n >> pCh = do c <- letter; return $ c >> simple = embeddedParser [1,2] >> >> -- the above result from sample I would like to get by running >> -- parseTest simple "0a1b2end" > > The way I see it, the defined datatype works but I am a bit clueless about > how to modify the parser to accept things of the type (e.g.): HData (IN (CH > (IN (CH (IN a))))) (and in general of any finite type embedded like this). > > Thanks in advance for your help, > George > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ryani.spam at gmail.com Mon Dec 1 21:31:26 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Dec 1 21:24:52 2008 Subject: [Haskell-cafe] Can anybody give me some advice on this? In-Reply-To: <2f9b2d30812011808j4c10d3e7s994ba3a2ceeb6cda@mail.gmail.com> References: <8c15bc480812011511l7203d055s4566eaa17e488ebf@mail.gmail.com> <2f9b2d30812011808j4c10d3e7s994ba3a2ceeb6cda@mail.gmail.com> Message-ID: <2f9b2d30812011831o6c5c5badqb530f2006a43fa72@mail.gmail.com> Also, if you can give up on the dependent types issue, and you just want the equivalent of "embeddedParser [1,2]", you have a problem that the type you are specifying is infinite; this is the cause of the "occurs checks" errors you are getting. Lets specify the type you are parsing directly, then abstract a bit: > -- your HData is just Maybe! > > data IN1 = IN1 Int (Maybe CH1) > data CH1 = CH1 Char (Maybe IN1) > sample :: Maybe IN1 > sample = Just $ > IN1 0 $ Just $ > CH1 'a' $ Just $ > IN1 1 $ Just $ > CH1 'b' $ Just $ > IN1 2 $ Nothing You can easily write a parser for this type with two mutually recursive parsers that parse IN1 and CH1; I'll leave that as an exercise for you. Now, you might not want to explicitly specify the type of the result in the data type; that's what you have done with your versions of IN and CH that take the "rest of the type" as an argument. But the problem with that approach is that the resultant type is *infinite*! > data > -- broken: > -- type ParserResult = Maybe (IN (Maybe (CH (Maybe (IN (Maybe ... But there is a great trick to solve this; another type can wrap the "fixpoint" of this type: > newtype Mu f = In (f (Mu f)) > out (In x) = x You can then use this structure to define the type of the parser: > data ResultOpen a = O | C (IN (ResultOpen (CH (ResultOpen a)))) > type Result = Mu ResultOpen What "Mu" does here is fill in the "a" in ResultOpen with (ResultOpen (ResultOpen (ResultOpen (ResultOpen ..., infinitely large. The price you pay for this infinite type is that you have to explicitly mark the boundaries with "In"; the constructor for "Mu": > sample2 :: Result > sample2 = In (C(IN 0 (C(CH 'a' (In (C(IN 1 (C(CH 'b' (In (C(IN 2 O)))))))))))) A parser for this type is also not too difficult to write; you just have to take care to use "In" and "out" in the right places. -- ryan On Mon, Dec 1, 2008 at 6:08 PM, Ryan Ingram wrote: > The problem is this: what is the type of "embeddedParser"? Unless you > can answer that question, you're not going to be able to write it. > > In particular, its *type* depends on the *value* of its argument; the > type of embeddedParser [1,2] is different from the type of > embeddedParser [1,1,2]. This isn't possible in Haskell; you need a > language with an even more exotic type system (Agda, for example) to > encode this dependency. Google "dependent types" for more > information. > > You can encode something similar using existentials: > > data Sealed p = forall a. Sealed (p a) > type ParseResult = Sealed HData > > ... > > case h of > 1 -> do > aux <- pInt > Sealed rest <- embeddedParser (t ++ [h]) > return (Sealed (C (In aux rest))) > > and a similar transformation on the (2) case and the "end" case; this > makes the type of embeddedParser into Parser ParseResult. What you > are doing here is saying that the result of a parse is an HData a for > *some* a, but you aren't saying which one. You extract the HData > from the existential when running the sub parser, then stuff it back > into another existential. > > But you can't extract the type out of the existential ever; it is > lost. In particular you can't prove to the compiler that the type > matches that of the [1,2] input and get back to the IN and CH values. > And you can't return a value that has been extracted out, you can only > stuff it back into another existential container or consume it in some > other way! > > A better option is to use a type that matches what you expect to > parse, or just use Data.Dynamic if you want multiple types. You > aren't going to get any benefit from "HData a" without a lot more > type-level work! > > Also, for your type list, it'd be much more efficient to use (cycle > types) to construct an infinite list (in finite space!) rather than > keep appending the head back onto the tail. > > 2008/12/1 Georgel Calin <6c5l7n@googlemail.com>: >> Hello everybody, >> >> I have a piece of code that gives me headaches for some time now. >> >> Simply put, I would like to know which is the best way to overpass a >> "Couldn't match expected type * against inferred type *"-error and an >> "Occurs check: cannot construct the infinite type:"-error in the following >> situation: >> >>> {-# OPTIONS -fglasgow-exts #-} >>> module Simple where >>> import Text.ParserCombinators.Parsec >>> >>> data HData a = O | C a deriving (Eq,Ord,Show) >>> data IN l = IN Int (HData l) deriving (Eq,Ord,Show) >>> data CH l = CH Char (HData l) deriving (Eq,Ord,Show) >>> -- data type is well-defined: >>> sample = C(IN 0 (C(CH 'a' (C(IN 1 (C(CH 'b' (C(IN 2 O))))))))) >>> >>> embeddedParser types = do string "end"; spaces; return O >>> {- >>> <|> do let h = head types >>> let t = tail types >>> case h of >>> 1 -> do aux <- pInt >>> rest <- embeddedParser $t++[h] >>> return $ C (IN aux rest) >>> 2 -> do aux <- pCh >>> rest <- embeddedParser $t++[h] >>> return $ C (CH aux rest) >>> _ -> error "unallowed type" >>> -} >>> pInt = do n <- fmap read $ many1 digit; return $ fromInteger n >>> pCh = do c <- letter; return $ c >>> simple = embeddedParser [1,2] >>> >>> -- the above result from sample I would like to get by running >>> -- parseTest simple "0a1b2end" >> >> The way I see it, the defined datatype works but I am a bit clueless about >> how to modify the parser to accept things of the type (e.g.): HData (IN (CH >> (IN (CH (IN a))))) (and in general of any finite type embedded like this). >> >> Thanks in advance for your help, >> George >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > From vanenkj at gmail.com Mon Dec 1 21:31:52 2008 From: vanenkj at gmail.com (John Van Enk) Date: Mon Dec 1 21:25:19 2008 Subject: [Haskell-cafe] global variables for foreign C functions In-Reply-To: <20081202013849.GA18561@sliver.repetae.net> References: <20081202003924.GC21677@Andrea.Nowhere.net> <2518b95d0812011655w2585995ega1aebbdc6e0e1cde@mail.gmail.com> <20081202013849.GA18561@sliver.repetae.net> Message-ID: I would find a ForeignData extension incredibly helpful. This will be crucial if Haskell ever wants to target out of the ordinary systems. /jve On Mon, Dec 1, 2008 at 8:38 PM, John Meacham wrote: > On Mon, Dec 01, 2008 at 04:55:14PM -0800, Evan Laforge wrote: > > On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato > > wrote: > > > Hello, > > > > > > I'm writing the bindings to a C library which uses, in some functions, > > > global variables. > > > > > > To make it clearer, those functions need a global variable to be > > > defined. A C program using my_function, one of the library functions, > > > would look like: > > > > I don't think you can use the FFI to declare symbols for C. One > > not-so-pretty but effective way to do it is create a stub.c with the > > variables declared along with setting functions, then bind those > > functions like any other. > > Yes, it is unfortunate this is the case. my ForeignData proposal was > meant to address this: > > http://hackage.haskell.org/trac/haskell-prime/wiki/ForeignData > > I am not entirely sure about the proposal as described, but I think > something like it should be done. > > John > > -- > John Meacham - ?repetae.net?john? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081201/fff84209/attachment.htm From allbery at ece.cmu.edu Mon Dec 1 21:47:38 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Dec 1 21:41:32 2008 Subject: [Haskell-cafe] Re: Binary Trees missing on hackage In-Reply-To: References: <4933C5D5.2000902@dfki.de> Message-ID: <6F033122-937D-4913-A33C-B5945C153A0F@ece.cmu.edu> On 2008 Dec 1, at 8:28, Andrew Wagner wrote: > Hm, I've been thinking about this this morning as I've gone about my > commute. I could indeed imagine a class like the following that had > multiple implementations like you're talking about: One can indeed --- but it turns out to be even more general than just trees. Go look at the Foldable and Traversable classes. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081201/b26491ae/attachment.htm From jason.dusek at gmail.com Mon Dec 1 22:05:19 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Dec 1 21:58:46 2008 Subject: [Haskell-cafe] bug in time libs? Message-ID: <42784f260812011905r39b0998jc33b1d3f2c5d60d5@mail.gmail.com> I'm on 6.10.1, using the libs provided with the binary of GHC for Mac OS X. I was fooling around with the time package in GHCi and something seems to be off. I have included a transcript. If I take a time diff, then the seconds are positive when the picos are negative and vice versa. -- _jsn |...transcript...| Prelude System.Time> :m + System.Time Prelude System.Time> t0 <- System.Time.getClockTime Prelude System.Time> t1 <- System.Time.getClockTime Prelude System.Time> diffClockTimes t0 t1 TimeDiff { tdYear = 0 , tdMonth = 0 , tdDay = 0 , tdHour = 0 , tdMin = 0 , tdSec = -7 , tdPicosec = 238846000000 } Prelude System.Time> diffClockTimes t1 t0 TimeDiff { tdYear = 0 , tdMonth = 0 , tdDay = 0 , tdHour = 0 , tdMin = 0 , tdSec = 7 , tdPicosec = -238846000000 } From skynare at gmail.com Mon Dec 1 22:30:20 2008 From: skynare at gmail.com (sam lee) Date: Mon Dec 1 22:23:47 2008 Subject: [Haskell-cafe] bug in time libs? In-Reply-To: <42784f260812011905r39b0998jc33b1d3f2c5d60d5@mail.gmail.com> References: <42784f260812011905r39b0998jc33b1d3f2c5d60d5@mail.gmail.com> Message-ID: <4e7aa0f80812011930i5139950do967debf5c6ecfed2@mail.gmail.com> I can't find document for System.Time . But I can import System.Time . It's weird... I can't find document for TimeDiff and related functions. I guess this is all deprecated. A related bug report: http://hackage.haskell.org/trac/ghc/ticket/2519 I would use Data.Time.Clock Prelude> :m + Data.Time.Clock Prelude Data.Time.Clock> getCurrentTime Prelude Data.Time.Clock> t0 <- getCurrentTime Prelude Data.Time.Clock> t1 <- getCurrentTime Prelude Data.Time.Clock> t0 Prelude Data.Time.Clock> diffUTCTime t0 t1 -2.912s Prelude Data.Time.Clock> diffUTCTime t1 t0 2.912s Prelude Data.Time.Clock> :t diffUTCTime t1 t0 diffUTCTime t1 t0 :: NominalDiffTime On Mon, Dec 1, 2008 at 10:05 PM, Jason Dusek wrote: > I'm on 6.10.1, using the libs provided with the binary of GHC > for Mac OS X. I was fooling around with the time package in > GHCi and something seems to be off. I have included a > transcript. > > If I take a time diff, then the seconds are positive when the > picos are negative and vice versa. > > -- > _jsn > > > |...transcript...| > > > Prelude System.Time> :m + System.Time > Prelude System.Time> t0 <- System.Time.getClockTime > Prelude System.Time> t1 <- System.Time.getClockTime > Prelude System.Time> diffClockTimes t0 t1 > TimeDiff { tdYear = 0 > , tdMonth = 0 > , tdDay = 0 > , tdHour = 0 > , tdMin = 0 > , tdSec = -7 > , tdPicosec = 238846000000 > } > Prelude System.Time> diffClockTimes t1 t0 > TimeDiff { tdYear = 0 > , tdMonth = 0 > , tdDay = 0 > , tdHour = 0 > , tdMin = 0 > , tdSec = 7 > , tdPicosec = -238846000000 > } > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mail at justinbogner.com Mon Dec 1 23:06:34 2008 From: mail at justinbogner.com (mail@justinbogner.com) Date: Mon Dec 1 23:00:10 2008 Subject: [Haskell-cafe] Re: Cabal References: <62A837ED-079C-4E15-8863-75AFCDA4BF28@cs.otago.ac.nz> <20081129033017.GB31753@sliver.repetae.net> <20081129113039.GA29053@petunia.outback.escape.de> <20081129193152.GA30959@scytale.galois.com> <20081129201651.GA8079@petunia.outback.escape.de> <916b84820811291737j71fe288ct1551242466399787@mail.gmail.com> <49327180.1080707@btinternet.com> <1228086519.10115.129.camel@localhost> <20081130231412.GB4008@scytale.galois.com> Message-ID: <87bpvv43w5.fsf@justinbogner.com> Don Stewart writes: > > I'm a fan of gitit, and its 46 dependencies, that install via > cabal-install. Pretty awesome. > gitit's 46 dependencies convinced me to install cabal-install, and now I couldn't be happier! From wren at freegeek.org Mon Dec 1 23:48:21 2008 From: wren at freegeek.org (wren ng thornton) Date: Mon Dec 1 23:41:48 2008 Subject: [Haskell-cafe] The Knight's Tour: solutions please In-Reply-To: <200812011801.09705.dan.doel@gmail.com> References: <20081130213102.GB3881@scytale.galois.com> <20081201183913.GA13054@zombie.inf.tu-dresden.de> <200812011801.09705.dan.doel@gmail.com> Message-ID: <4934BE15.4070406@freegeek.org> Dan Doel wrote: > On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote: > > As one of the posters there points out, for n=100 the program doesn't > > actually backtrack if the 'loneliest neighbour' heuristic is used. Do any > > of our programs finish quickly for n=99? The Python one doesn't. > > Nothing I tried finished. Do you have any figures on how much backtracking > needs to be done to find a solution for n=99 (there is a solution, right?)? I > tweaked the continuation version to print k when it backtracks, and it > continuously spit out numbers around 9790. I get the feeling it doesn't matter > how fast your backtracking infrastructure is in this case as long as you use > the same general algorithm. > > On a long shot, I even tried using Logic's alternate bind based on fair > choice, but that didn't seem to be any better. FWIW, fair choice (interleave) is much slower than unfair choice (mplus) in logict. Unfortunately this means you need to know a lot about the problem domain to correctly choose between them when maximal performance is at stake; just using fair choice everywhere costs too much for many problems. -- Live well, ~wren From blgeorge at fastmail.fm Tue Dec 2 00:38:25 2008 From: blgeorge at fastmail.fm (Ben George) Date: Tue Dec 2 00:31:53 2008 Subject: [Haskell-cafe] System.IO.UTF8 Problem Message-ID: <1228196305.23867.1287752941@webmail.messagingengine.com> Hi, so I've been working with System.IO.UTF8 trying to get it to render Japanese characters correctly. Using just IO I've gotten it to output the correct unicode values, however, replacing the IO.putStrLn commands with System.IO.UTF8 yielded some strange errors. I went through the program and replaced the System.IO.UTF8 putStrLn and hGetLine commands with their "normal" IO counterparts, however, simply having the "import System.IO.UTF8" line at the beginning of the file causes an error during compilation. $ghc file.hs compilation IS NOT required byteindex.o: In function `sKE_info': (.text+0x8bf): undefined reference to `__stginit_utf8zmstringzm0zi3zi3_SystemziIOziUTF8_' collect2: ld returned 1 exit status Below is the output of ghc -v. I am running Ubuntu 7.10 gutsy. I have been getting the same error whether GHC was compiled from binaries or source. Currently I am running GHC (version 6.8.3) compiled from source. $ ghc -v file.hs Glasgow Haskell Compiler, Version 6.8.3, for Haskell 98, stage 2 booted by GHC version 6.8.3 Using package config file: /usr/local/lib/ghc-6.8.3/package.conf wired-in package base mapped to base-3.0.2.0 wired-in package rts mapped to rts-1.0 wired-in package haskell98 mapped to haskell98-1.0.1.0 wired-in package template-haskell mapped to template-haskell-2.2.0.0 wired-in package ndp not found. Hsc static flags: -static Created temporary directory: /tmp/ghc6586_0 *** Checking old interface for main:Main: compilation IS NOT required *** Touching object file: touch byteindex.o *** Linker: gcc -v -o a.out -DDONT_WANT_WIN32_DLL_SUPPORT byteindex.o -L/usr/local/lib/ghc-6.8.3/lib/haskell98-1.0.1.0 -L/usr/local/lib/ghc-6.8.3/lib/array-0.1.0.0 -L/usr/local/lib/ghc-6.8.3/lib/process-1.0.0.1 -L/usr/local/lib/ghc-6.8.3/lib/unix-2.3.0.1 -L/usr/local/lib/ghc-6.8.3/lib/random-1.0.0.0 -L/usr/local/lib/ghc-6.8.3/lib/directory-1.0.0.1 -L/usr/local/lib/ghc-6.8.3/lib/filepath-1.1.0.0 -L/usr/local/lib/ghc-6.8.3/lib/old-time-1.0.0.0 -L/usr/local/lib/ghc-6.8.3/lib/old-locale-1.0.0.0 -L/usr/local/lib/ghc-6.8.3/lib/base-3.0.2.0 -L/usr/local/lib/ghc-6.8.3 -lHShaskell98-1.0.1.0 -lHSarray-0.1.0.0 -lHSprocess-1.0.0.1 -lHSunix-2.3.0.1 -lutil -ldl -lHSrandom-1.0.0.0 -lHSdirectory-1.0.0.1 -lHSfilepath-1.1.0.0 -lHSold-time-1.0.0.0 -lHSold-locale-1.0.0.0 -lHSbase-3.0.2.0 -lHSrts -lm -lgmp -ldl -lrt -u base_GHCziBase_Izh_static_info -u base_GHCziBase_Czh_static_info -u base_GHCziFloat_Fzh_static_info -u base_GHCziFloat_Dzh_static_info -u base_GHCziPtr_Ptr_static_info -u base_GHCziWord_Wzh_static_info -u base_GHCziInt_I8zh_static_info -u base_GHCziInt_I16zh_static_info -u base_GHCziInt_I32zh_static_info -u base_GHCziInt_I64zh_static_info -u base_GHCziWord_W8zh_static_info -u base_GHCziWord_W16zh_static_info -u base_GHCziWord_W32zh_static_info -u base_GHCziWord_W64zh_static_info -u base_GHCziStable_StablePtr_static_info -u base_GHCziBase_Izh_con_info -u base_GHCziBase_Czh_con_info -u base_GHCziFloat_Fzh_con_info -u base_GHCziFloat_Dzh_con_info -u base_GHCziPtr_Ptr_con_info -u base_GHCziPtr_FunPtr_con_info -u base_GHCziStable_StablePtr_con_info -u base_GHCziBase_False_closure -u base_GHCziBase_True_closure -u base_GHCziPack_unpackCString_closure -u base_GHCziIOBase_stackOverflow_closure -u base_GHCziIOBase_heapOverflow_closure -u base_GHCziIOBase_NonTermination_closure -u base_GHCziIOBase_BlockedOnDeadMVar_closure -u base_GHCziIOBase_BlockedIndefinitely_closure -u base_GHCziIOBase_Deadlock_closure -u base_GHCziIOBase_NestedAtomically_closure -u base_GHCziWeak_runFinalizzerBatch_closure -u base_GHCziConc_ensureIOManagerIsRunning_closure Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu Thread model: posix gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2) /usr/lib/gcc/i486-linux-gnu/4.1.3/collect2 --eh-frame-hdr -m elf_i386 --hash-style=both -dynamic-linker /lib/ld-linux.so.2 -o a.out -u base_GHCziBase_Izh_static_info -u base_GHCziBase_Czh_static_info -u base_GHCziFloat_Fzh_static_info -u base_GHCziFloat_Dzh_static_info -u base_GHCziPtr_Ptr_static_info -u base_GHCziWord_Wzh_static_info -u base_GHCziInt_I8zh_static_info -u base_GHCziInt_I16zh_static_info -u base_GHCziInt_I32zh_static_info -u base_GHCziInt_I64zh_static_info -u base_GHCziWord_W8zh_static_info -u base_GHCziWord_W16zh_static_info -u base_GHCziWord_W32zh_static_info -u base_GHCziWord_W64zh_static_info -u base_GHCziStable_StablePtr_static_info -u base_GHCziBase_Izh_con_info -u base_GHCziBase_Czh_con_info -u base_GHCziFloat_Fzh_con_info -u base_GHCziFloat_Dzh_con_info -u base_GHCziPtr_Ptr_con_info -u base_GHCziPtr_FunPtr_con_info -u base_GHCziStable_StablePtr_con_info -u base_GHCziBase_False_closure -u base_GHCziBase_True_closure -u base_GHCziPack_unpackCString_closure -u base_GHCziIOBase_stackOverflow_closure -u base_GHCziIOBase_heapOverflow_closure -u base_GHCziIOBase_NonTermination_closure -u base_GHCziIOBase_BlockedOnDeadMVar_closure -u base_GHCziIOBase_BlockedIndefinitely_closure -u base_GHCziIOBase_Deadlock_closure -u base_GHCziIOBase_NestedAtomically_closure -u base_GHCziWeak_runFinalizzerBatch_closure -u base_GHCziConc_ensureIOManagerIsRunning_closure /usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.1.3/crtbegin.o -L/usr/local/lib/ghc-6.8.3/lib/haskell98-1.0.1.0 -L/usr/local/lib/ghc-6.8.3/lib/array-0.1.0.0 -L/usr/local/lib/ghc-6.8.3/lib/process-1.0.0.1 -L/usr/local/lib/ghc-6.8.3/lib/unix-2.3.0.1 -L/usr/local/lib/ghc-6.8.3/lib/random-1.0.0.0 -L/usr/local/lib/ghc-6.8.3/lib/directory-1.0.0.1 -L/usr/local/lib/ghc-6.8.3/lib/filepath-1.1.0.0 -L/usr/local/lib/ghc-6.8.3/lib/old-time-1.0.0.0 -L/usr/local/lib/ghc-6.8.3/lib/old-locale-1.0.0.0 -L/usr/local/lib/ghc-6.8.3/lib/base-3.0.2.0 -L/usr/local/lib/ghc-6.8.3 -L/usr/lib/gcc/i486-linux-gnu/4.1.3 -L/usr/lib/gcc/i486-linux-gnu/4.1.3 -L/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib byteindex.o -lHShaskell98-1.0.1.0 -lHSarray-0.1.0.0 -lHSprocess-1.0.0.1 -lHSunix-2.3.0.1 -lutil -ldl -lHSrandom-1.0.0.0 -lHSdirectory-1.0.0.1 -lHSfilepath-1.1.0.0 -lHSold-time-1.0.0.0 -lHSold-locale-1.0.0.0 -lHSbase-3.0.2.0 -lHSrts -lm -lgmp -ldl -lrt -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i486-linux-gnu/4.1.3/crtend.o /usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crtn.o byteindex.o: In function `sKE_info': (.text+0x8bf): undefined reference to `__stginit_utf8zmstringzm0zi3zi3_SystemziIOziUTF8_' collect2: ld returned 1 exit status *** Deleting temp files: Deleting: /tmp/ghc6586_0/ghc6586_0.s Warning: deleting non-existent /tmp/ghc6586_0/ghc6586_0.s *** Deleting temp dirs: Deleting: /tmp/ghc6586_0 Any help would be greatly appreciated. -- Ben George blgeorge@fastmail.fm -- http://www.fastmail.fm - The way an email service should be From allbery at ece.cmu.edu Tue Dec 2 00:55:26 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Dec 2 00:49:04 2008 Subject: [Haskell-cafe] System.IO.UTF8 Problem In-Reply-To: <1228196305.23867.1287752941@webmail.messagingengine.com> References: <1228196305.23867.1287752941@webmail.messagingengine.com> Message-ID: <2AA2D2DF-186B-4DB6-9DB9-996A7C61EA43@ece.cmu.edu> On 2008 Dec 2, at 0:38, Ben George wrote: > $ghc file.hs > compilation IS NOT required > byteindex.o: In function `sKE_info': > (.text+0x8bf): undefined reference to > `__stginit_utf8zmstringzm0zi3zi3_SystemziIOziUTF8_' > collect2: ld returned 1 exit status Use ghc --make so it looks up the dependencies for System.IO.UTF8 automatically. Otherwise you need to add them explicitly with - package arguments. -- 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 jason.dusek at gmail.com Tue Dec 2 01:43:26 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Dec 2 01:36:52 2008 Subject: [Haskell-cafe] serious defect in system-uuid Message-ID: <42784f260812012243i2338e091x1cda7426a516073e@mail.gmail.com> I discovered that my UUID type causes a <> when tested for equality. Anyone who is using `system-uuid`, please upgrade to version 1.0.2. -- _jsn From lazycat.manatee at gmail.com Tue Dec 2 01:50:40 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Dec 2 02:08:33 2008 Subject: [Haskell-cafe] Compatible problem with GHC 6.10.1 Message-ID: <878wqzxe7z.fsf@debian.domain> Hi all, I use Debian and GHC 6.8.2-7 Have install cabal, xmonad, gtk2hs with GHC 6.8.2-7 But when upgrade to GHC 6.10.1, i failed to install XMonad 0.8 and gtk2hs 0.9.13 I heard someone install success with develop version. So anyone success install XMonad and gtk2hs with GHC 6.10.1? BTW, i want to know the details compatible problem between 6.8 with 6.10? Is most libraries have compatible with GHC 6.10.1? Any suggestions? Thanks. -- Andy From allbery at ece.cmu.edu Tue Dec 2 02:19:59 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Dec 2 02:13:39 2008 Subject: [Haskell-cafe] Compatible problem with GHC 6.10.1 In-Reply-To: <878wqzxe7z.fsf@debian.domain> References: <878wqzxe7z.fsf@debian.domain> Message-ID: <5740FB12-D9FF-4BEC-A6B8-B6E7E688D4D8@ece.cmu.edu> On 2008 Dec 2, at 1:50, Andy Stewart wrote: > BTW, i want to know the details compatible problem between 6.8 with > 6.10? > Is most libraries have compatible with GHC 6.10.1? The compatibility issue is mainly that GHC 6.10 ships with base-4.0, which as with past major revisions is not compatible with earlier major versions. There are some tricks that can be used to make cabal- based packages use the compatibility base-3 package included; see the wiki page http://www.haskell.org/haskellwiki/Upgrading_packages for details. -- 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 colin at colina.demon.co.uk Tue Dec 2 02:21:16 2008 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Dec 2 02:14:43 2008 Subject: [Haskell-cafe] Compatible problem with GHC 6.10.1 In-Reply-To: <878wqzxe7z.fsf@debian.domain> (Andy Stewart's message of "Tue\, 02 Dec 2008 14\:50\:40 +0800") References: <878wqzxe7z.fsf@debian.domain> Message-ID: >>>>> "Andy" == Andy Stewart writes: Andy> But when upgrade to GHC 6.10.1, i failed to install XMonad Andy> 0.8 and gtk2hs 0.9.13 I heard someone install success with Andy> develop version. So anyone success install XMonad and Andy> gtk2hs with GHC 6.10.1? I am using the development version of gtk2hs OK with GHC 6.10.1. -- Colin Adams Preston Lancashire From lazycat.manatee at gmail.com Tue Dec 2 02:43:42 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Dec 2 02:38:42 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 References: <878wqzxe7z.fsf@debian.domain> Message-ID: <87iqq3c98x.fsf@debian.domain> Thank you very much. So anyone install XMonad with GHC 6.10.1 success? -- Andy Colin Paul Adams writes: >>>>>> "Andy" == Andy Stewart writes: > > Andy> But when upgrade to GHC 6.10.1, i failed to install XMonad > Andy> 0.8 and gtk2hs 0.9.13 I heard someone install success with > Andy> develop version. So anyone success install XMonad and > Andy> gtk2hs with GHC 6.10.1? > > I am using the development version of gtk2hs OK with GHC 6.10.1. From lazycat.manatee at gmail.com Tue Dec 2 02:48:54 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Dec 2 02:48:30 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 References: <878wqzxe7z.fsf@debian.domain> Message-ID: <87d4gbc909.fsf@debian.domain> Hi Colin, Colin Paul Adams writes: >>>>>> "Andy" == Andy Stewart writes: > > Andy> But when upgrade to GHC 6.10.1, i failed to install XMonad > Andy> 0.8 and gtk2hs 0.9.13 I heard someone install success with > Andy> develop version. So anyone success install XMonad and > Andy> gtk2hs with GHC 6.10.1? > > I am using the development version of gtk2hs OK with GHC 6.10.1. When i ./configure gtk2hs souce code, i will got below information: ,---- | * The following packages will be built: | * | * glib : yes | * gtk : yes | * glade : no | * cairo : yes | * svgcairo : no | * gtkglext : no | * gconf : no | * sourceview : no | * mozembed : no | * soegtk : yes | * gnomevfs : no | * gstreamer : no | * documentation : no `---- So i want to ask, what libraries need to install for support full gtk2hs? Thank you very much! -- Andy From martin.hofmann at uni-bamberg.de Tue Dec 2 02:59:09 2008 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Tue Dec 2 02:50:03 2008 Subject: [Haskell-cafe] What causes <>? Message-ID: <1228204749.6005.22.camel@ios.cogsys.wiai.uni-bamberg.de> I am picking up a discussion with the same topic from haskell-users on 8th November. Thunks with reference on themselves was mentioned as main reason for <>. > A safe recursive definition would be > let x = Foo (x+1) > However, if you leave out the constructor, > let x = x + 1 > you get a <> (or a deadlock). > Are there any other reasons? I am trying to debug monadic code which stores state information in a record maintaining several Data.Maps, but in vein so far. A state is modified/changed in several steps by a compound function i.e. changeA $ changeB $ changeC state Is code using mtl, records or Maps more prone to <> or does this not matter at all. How can I identify self-referencing thunks more easily? Is there any rule of thumb to prevent <>? Are there any less obvious newbie mistakes causing < then the one above? Any comments, experience, and tips are highly appreciated. Thanks, Martin From DekuDekuplex at Yahoo.com Tue Dec 2 03:28:57 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Dec 2 03:22:34 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: Haskell Communities and Activities Report (15th ed., November 2008) References: <492F9701.9010707@tcs.inf.tu-dresden.de> <20081129001530.GN27887@scytale.galois.com> Message-ID: <4ep9j4h9deshvgt8vv2ofi8j8pnclp83n8@4ax.com> On Fri, 28 Nov 2008 16:15:30 -0800, Don Stewart wrote: >Good work! > >It is always interesting to see the secret Haskell projects that only >get announced via the HCAR. Things not on haskell@ or on hackage. > >For example, this under-the-radar project: > > http://www.haskell.org/communities/11-2008/html/report.html#sect7.7 > > 7.7 IVU Traffic Technologies AG Rostering Group > >Haskell to solve constraints on EU bus timetables! In production use! Speaking of production use, one type of project that would be interesting would be a study examining how Haskell can increase programmer productivity for production use for programmers who are not necessarily gifted in programming, but whose forte may lie in another field and who are very interested in functional programming; i.e., some type of tabulated data (preferably a graph, although a table would work, too) of data quantifying how useful Haskell is in allowing one whose forte may not necessarily be in programming (say, a physicist, mathematician, or even a translator who happens to have an algorithmically-focused computer science degree) to equal or excel the productivity of, say, a gifted C/C++ programmer in, say, setting up a commercial Web site. The reason is that recently, there has been news of people in academia leaving for other realms because of worsening conditions (see "As strikes begin, lecturer quits to become plumber" at http://www.guardian.co.uk/uk/2004/feb/24/lecturerspay.highereducation, and "Why I am Not a Professor OR The Decline and Fall of the British University" at http://www.lambdassociates.org/blog/decline.htm). Up to know, my dream was to publish a paper on type theory to motivate study of Haskell, but now it looks like I may need to aim for creating a commercial Web site. However, I am not sure of being able to compete with commercial Web sites, because I am more of a writer/translator who happens to like functional programming than a real-life programmer. I've already seen such articles as "Why Functional Programming Matters" (see http://www.md.chalmers.se/~rjmh/Papers/whyfp.html), "Why Haskell Matters" (see http://www.haskell.org/haskellwiki/Why_Haskell_matters), and "Beating the Averages" (see http://www.paulgraham.com/avg.html). However, these essays tend to focus on how a functional language FL is structurally better than non-functional languages NFL in general, without specifying the skill-level of the programmer. Instead, it would be interesting to find the minimum skill-level s necessary for, say, somebody whose forte is not in programming, but who, say, studies functional programming as a hobby, to use Haskell as a tool in achieving a productivity level equivalent to that of a gifted C/C++ programmer. To sum: Can a theoretically-minded Haskell student who studies Haskell out of interest in type theory compete with star C/C++ programmers in developing, say, commercial Web sites? This is not quite clear, because even if Haskell can increase programmer productivity by tenfold, a star programmer can also be more productive than an average programmer by tenfold. How risky is this challenge? -- Benjamin L. Russell > >-- Don > > >voigt: >> On behalf of the many, many contributors, I am pleased to announce >> that the >> >> Haskell Communities and Activities Report >> (15th edition, November 2008) >> >> http://www.haskell.org/communities/ >> >> is now available from the Haskell Communities home page in PDF and >> HTML formats. From bertram.felgenhauer at googlemail.com Tue Dec 2 03:29:27 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Tue Dec 2 03:22:58 2008 Subject: [Haskell-cafe] The Knight's Tour: solutions please In-Reply-To: <200812011801.09705.dan.doel@gmail.com> References: <20081130213102.GB3881@scytale.galois.com> <20081201183913.GA13054@zombie.inf.tu-dresden.de> <200812011801.09705.dan.doel@gmail.com> Message-ID: <20081202082927.GA4306@zombie.inf.tu-dresden.de> Dan Doel wrote: > On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote: > > As one of the posters there points out, for n=100 the program doesn't > > actually backtrack if the 'loneliest neighbour' heuristic is used. Do > > any of our programs finish quickly for n=99? The Python one doesn't. > > Nothing I tried finished. Do you have any figures on how much backtracking > needs to be done to find a solution for n=99 (there is a solution, right?)? Yes, there is a solution. After changing successors n b = sortWith (length . succs) . succs to successors n b = sortWith (length . (succs =<<) . succs) . succs in the LogicT solution, it finds one with no backtracking at all. This heuristic fails on other n though, n=8 and n=66 at least. The obvious next step, successors n b = sortWith (length . (succs =<<) . (succs =<<) . succs) . succs works without backtracking up to n=100. These improved heuristics don't come cheap though. Here are some timings for n = 100: LogicT : 0.48 user 0.00 system 0:00.48 elapsed LogicT' : 2.16 user 0.00 system 0:02.16 elapsed LogicT'': 13.84 user 0.01 system 0:13.86 elapsed Bertram From oleg at okmij.org Tue Dec 2 03:30:37 2008 From: oleg at okmij.org (oleg@okmij.org) Date: Tue Dec 2 03:24:26 2008 Subject: [Haskell-cafe] The Knight's Tour: solutions please Message-ID: <20081202083037.74165AB0F@Adric.metnet.fnmoc.navy.mil> Yes, there is a solution for n=99 and for n=100 for that matter -- which can be found under one second. I only had to make a trivial modification to the previously posted code > tour n k s b | k > n*n = return b > | otherwise = do next <- (foldr mplus mzero).map return $ successors n b s > tour n (k+1) next $ insrt next k b I replaced foldl1 mplus with foldr mplus zero. Here are the results: for n=99, the first line of the board is 1 4 2885 214 309 6 311 216 307 8 315 218 305 10 319 220 303 12 2021 222 301 14 1727 224 299 16 1699 226 297 18 1561 228 295 20 1247 230 293 22 1227 232 291 24 1165 234 289 26 1007 236 287 28 965 238 285 30 775 240 283 32 759 242 281 34 625 244 279 36 559 246 277 38 543 248 275 40 455 250 273 42 435 252 271 44 407 254 269 46 377 256 267 48 365 258 65 50 63 60 67 52 55 time is 0m0.730s n=100 1 4 205 9996 209 6 207 9940 211 8 9897 9900 213 10 9895 9906 215 12 9809 9880 217 14 9807 9740 219 16 9799 9072 221 18 8445 8864 223 20 8443 8378 225 22 8347 8352 227 24 8331 7860 229 26 7863 7844 231 28 7749 7754 233 30 7735 7742 235 32 7733 7320 237 34 677 640 239 36 597 568 241 38 535 540 243 40 517 500 245 42 473 452 247 44 371 358 249 46 305 310 251 48 293 286 253 50 291 270 255 52 259 262 time is 0m0.373s For n=101, time is 0m0.388s wren ng thornton wrote: > FWIW, fair choice (interleave) is much slower than unfair choice (mplus) > in logict. Unfortunately this means you need to know a lot about the > problem domain to correctly choose between them when maximal performance > is at stake; just using fair choice everywhere costs too much for many > problems. I believe that FBackTrack relieves one from making the above choice: the ordinary mplus is FBackTrack is both fair and speedy. There is no longer any need for interleave; btw, interleave does not ensure completeness, whereas FBackTrack, I conjecture, implements a complete search procedure: if there is a solution, FBackTrack will eventually find one. The only `drawback' of using FBackTrack is that the order of the answers (if there are several) is essentially unpredictable. Informally, the answers are delivered in the order of the difficulty of finding them. This drawback is relative however: if we insist that the sequence of answers of (m1 `mplus` m2) is the concatenation of the sequences of answers of m1 and then m2, our search procedure is incomplete. From vigalchin at gmail.com Tue Dec 2 03:48:40 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 2 03:42:12 2008 Subject: [Haskell-cafe] import Message-ID: <5ae4f2ba0812020048s69741039jf7615d64e9af47cb@mail.gmail.com> Hello, I am a little uncertain about "import" semantics in a hierarchical package ... i.e. if I import the root of a package root do I get everything under the "root's" namespace, i.e. the namespace tree? thanks, vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/82e41216/attachment.htm From blancolioni at gmail.com Tue Dec 2 04:32:12 2008 From: blancolioni at gmail.com (Fraser Wilson) Date: Tue Dec 2 04:25:38 2008 Subject: [Haskell-cafe] GHC on Fedora 10 - getMBlock: mmap: Permission denied Message-ID: Hi all, Has anybody seen this? I thought it might be an SELinux thing, but then I wouldn't expect GHC or darcs to run. Audley is a fairly simple program in operating system feature terms, but I get the same error with anything I build myself. [fraser@astroboy audley]$ ./dist/build/audley/audley audley: internal error: getMBlock: mmap: Permission denied (GHC version 6.8.3 for i386_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Aborted [fraser@astroboy audley]$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.3 [fraser@astroboy audley]$ cat /proc/version Linux version 2.6.27-0.352.rc7.git1.fc10.i686 ( mockbuild@x86-5.fedora.phx.redhat.com) (gcc version 4.3.2 20080917 (Red Hat 4.3.2-4) (GCC) ) #1 SMP Tue Sep 23 21:26:04 EDT 2008 [fraser@astroboy audley]$ cheers, Fraser. -- http://thewhitelion.org/mysister -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/6f1a5506/attachment.htm From bulat.ziganshin at gmail.com Tue Dec 2 04:45:47 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Dec 2 04:40:00 2008 Subject: [Haskell-cafe] import In-Reply-To: <5ae4f2ba0812020048s69741039jf7615d64e9af47cb@mail.gmail.com> References: <5ae4f2ba0812020048s69741039jf7615d64e9af47cb@mail.gmail.com> Message-ID: <241515755.20081202124547@gmail.com> Hello Vasili, Tuesday, December 2, 2008, 11:48:40 AM, you wrote: > ???? I am a little uncertain about "import" semantics in a > hierarchical package ... i.e. if I import the root of a package root > do I get everything under the "root's" namespace, i.e. the namespace tree? no. you import just *module*, and it gives you just the identifiers exported by module (by default - all symbols *defined* in this module) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lrpalmer at gmail.com Tue Dec 2 04:59:07 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Dec 2 04:52:32 2008 Subject: [Haskell-cafe] import In-Reply-To: <5ae4f2ba0812020048s69741039jf7615d64e9af47cb@mail.gmail.com> References: <5ae4f2ba0812020048s69741039jf7615d64e9af47cb@mail.gmail.com> Message-ID: <7ca3f0160812020159j6cf28632w746cfa8d792414cd@mail.gmail.com> 2008/12/2 Galchin, Vasili : > Hello, > > I am a little uncertain about "import" semantics in a hierarchical > package ... i.e. if I import the root of a package root do I get everything > under the "root's" namespace, i.e. the namespace tree? There is nothing at all magical about the . in a package name, other than that it is replaced by a / when searching for modules in a directory tree. But you should treat it as any other identifier character. Any hierarchy is purely incidental :-) Luke From duncan.coutts at worc.ox.ac.uk Tue Dec 2 05:44:40 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 2 05:38:10 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 In-Reply-To: <87d4gbc909.fsf@debian.domain> References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> Message-ID: <1228214680.10115.154.camel@localhost> On Tue, 2008-12-02 at 15:48 +0800, Andy Stewart wrote: > When i ./configure gtk2hs souce code, i will got below information: > > ,---- > | * The following packages will be built: > | * > | * glib : yes > | * gtk : yes > | * glade : no > | * cairo : yes > | * svgcairo : no > | * gtkglext : no > | * gconf : no > | * sourceview : no > | * mozembed : no > | * soegtk : yes > | * gnomevfs : no > | * gstreamer : no > | * documentation : no > `---- > > So i want to ask, what libraries need to install for support full > gtk2hs? Those names are the names of the Haskell components/packages. All of them (except soegtk) are wrappers for C libraries with similar names. So you need to install the system packages that contain the development files for those C libraries. For example the system package for glib might be called something like "glib-dev" or "glib-devel". On some systems they also have more numbers in like "glib2-devel" or be prefixed with "lib", like "libglib-dev". You almost certainly have the runtime files for all these packages installed already, so it's only the "dev"/"devel" variants that you need to install. Duncan From arumakanil at gmail.com Tue Dec 2 05:56:06 2008 From: arumakanil at gmail.com (nml) Date: Tue Dec 2 05:49:33 2008 Subject: [Haskell-cafe] Moving the messages for compiler to another file? Message-ID: <531137340812020256v49280d4eh19e0271123c70a16@mail.gmail.com> How about moving the messages for compiler to an additional file? My motivation is that we often face a trade-off between aesthetical(elegant code) and practical(efficient code). Like pragmas and strictness annotations, I often feel they make the source code ugly. They don't affect the semantics of our programs, do they? Some people would say this beautifying should be accomplished by an editor, like hiding/showing option for those information. But such separation has additional benefits. For instance, making the source code more compiler-independent. (yeah, this is not the case with language-extensions) And we avoid dispersing those information among our lines. (or even files) In some cases, it would be convenient. I'm not sure if this idea is reasonable, reachable or just naive. Suggestions? Best regards -nml From colin at colina.demon.co.uk Tue Dec 2 05:59:45 2008 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Dec 2 05:53:17 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 In-Reply-To: <1228214680.10115.154.camel@localhost> (Duncan Coutts's message of "Tue\, 02 Dec 2008 10\:44\:40 +0000") References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> <1228214680.10115.154.camel@localhost> Message-ID: >>>>> "Duncan" == Duncan Coutts writes: Duncan> Those names are the names of the Haskell Duncan> components/packages. All of them (except soegtk) are Duncan> wrappers for C libraries with similar names. So you need Duncan> to install the system packages that contain the Duncan> development files for those C libraries. For example the Duncan> system package for glib might be called something like Duncan> "glib-dev" or "glib-devel". On some systems they also have Duncan> more numbers in like "glib2-devel" or be prefixed with Duncan> "lib", like "libglib-dev". Do you know the names of the Fedora 10 packages needed for sourceview, mozembed and documentation? -- Colin Adams Preston Lancashire From colin at colina.demon.co.uk Tue Dec 2 06:01:53 2008 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Dec 2 05:55:23 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 In-Reply-To: <1228214680.10115.154.camel@localhost> (Duncan Coutts's message of "Tue\, 02 Dec 2008 10\:44\:40 +0000") References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> <1228214680.10115.154.camel@localhost> Message-ID: >>>>> "Duncan" == Duncan Coutts writes: >> gstreamer Duncan> Those names are the names of the Haskell Duncan> components/packages. All of them (except soegtk) are Duncan> wrappers for C libraries with similar names. So you need Duncan> to install the system packages that contain the Duncan> development files for those C libraries. For example the Duncan> system package for glib might be called something like Duncan> "glib-dev" or "glib-devel". On some systems they also have Duncan> more numbers in like "glib2-devel" or be prefixed with Duncan> "lib", like "libglib-dev". I have gstreamer-devel installed, but configure doesn't find it. -- Colin Adams Preston Lancashire From vigalchin at gmail.com Tue Dec 2 06:08:03 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 2 06:01:29 2008 Subject: [Haskell-cafe] import In-Reply-To: <241515755.20081202124547@gmail.com> References: <5ae4f2ba0812020048s69741039jf7615d64e9af47cb@mail.gmail.com> <241515755.20081202124547@gmail.com> Message-ID: <5ae4f2ba0812020308k7f285004h63ce6b32b8f3362a@mail.gmail.com> specifically I am concerned about ByteString and underlying nodes .. ??? On Tue, Dec 2, 2008 at 3:45 AM, Bulat Ziganshin wrote: > Hello Vasili, > > Tuesday, December 2, 2008, 11:48:40 AM, you wrote: > > I am a little uncertain about "import" semantics in a > > hierarchical package ... i.e. if I import the root of a package root > > do I get everything under the "root's" namespace, i.e. the namespace > tree? > > no. you import just *module*, and it gives you just the identifiers > exported by module (by default - all symbols *defined* in this module) > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/d154be48/attachment.htm From bulat.ziganshin at gmail.com Tue Dec 2 06:22:41 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Dec 2 06:16:52 2008 Subject: [Haskell-cafe] import In-Reply-To: <5ae4f2ba0812020308k7f285004h63ce6b32b8f3362a@mail.gmail.com> References: <5ae4f2ba0812020048s69741039jf7615d64e9af47cb@mail.gmail.com> <241515755.20081202124547@gmail.com> <5ae4f2ba0812020308k7f285004h63ce6b32b8f3362a@mail.gmail.com> Message-ID: <902120023.20081202142241@gmail.com> Hello Vasili, Tuesday, December 2, 2008, 2:08:03 PM, you wrote: it's just convention to make modules like this: module System.Stream ( module System.Stream.Class, module System.Stream.Transformer, module System.Stream.Instance, module System.Stream.Utils, ) where import System.Stream.Class import System.Stream.Transformer import System.Stream.Instance import System.Stream.Utils > specifically I am concerned about ByteString and underlying nodes .. ??? > On Tue, Dec 2, 2008 at 3:45 AM, Bulat Ziganshin > wrote: > > Hello Vasili, > > Tuesday, December 2, 2008, 11:48:40 AM, you wrote: >> ???? I am a little uncertain about "import" semantics in a >> hierarchical package ... i.e. if I import the root of a package root >> do I get everything under the "root's" namespace, i.e. the namespace tree? > > > no. you import just *module*, and it gives you just the identifiers > exported by module (by default - all symbols *defined* in this module) > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > > > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lazycat.manatee at gmail.com Tue Dec 2 06:32:18 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Dec 2 06:28:44 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> <1228214680.10115.154.camel@localhost> Message-ID: <87iqq2dd8d.fsf@debian.domain> Hi all, Thanks for your help. I have install all depend with below Debian package: libglade2-dev libgtksourceview-dev libgconf2-dev librsvg2-dev libgstreamer-plugins-base0.10-dev libgstreamer0.10-dev libgtkglext1-dev libgnomevfs2-dev xulrunner-dev Colin Paul Adams writes: >>>>>> "Duncan" == Duncan Coutts writes: > > Duncan> Those names are the names of the Haskell > Duncan> components/packages. All of them (except soegtk) are > Duncan> wrappers for C libraries with similar names. So you need > Duncan> to install the system packages that contain the > Duncan> development files for those C libraries. For example the > Duncan> system package for glib might be called something like > Duncan> "glib-dev" or "glib-devel". On some systems they also have > Duncan> more numbers in like "glib2-devel" or be prefixed with > Duncan> "lib", like "libglib-dev". > > Do you know the names of the Fedora 10 packages needed for sourceview, > mozembed and documentation? I think sourceview is libgtksourceview-dev, mozembed is xulrunner-dev. Document just document and example, i don't install it. I doesn't use Fedora 10, but i think you can those packages from Debian package name. -- Andy From lazycat.manatee at gmail.com Tue Dec 2 06:35:11 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Dec 2 06:33:46 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> <1228214680.10115.154.camel@localhost> Message-ID: <87d4gadd3k.fsf@debian.domain> Colin Paul Adams writes: >>>>>> "Duncan" == Duncan Coutts writes: > > >> gstreamer > > Duncan> Those names are the names of the Haskell > Duncan> components/packages. All of them (except soegtk) are > Duncan> wrappers for C libraries with similar names. So you need > Duncan> to install the system packages that contain the > Duncan> development files for those C libraries. For example the > Duncan> system package for glib might be called something like > Duncan> "glib-dev" or "glib-devel". On some systems they also have > Duncan> more numbers in like "glib2-devel" or be prefixed with > Duncan> "lib", like "libglib-dev". > > I have gstreamer-devel installed, but configure doesn't find it. I use Debian, about gstreamer need libgstreamer-plugins-base0.10-dev and libgstreamer0.10-dev. libgstreamer-plugins-base0-dev is "base" set for GStreamer development files libgstreamer0.10-dev is core development files for GStreamer development From lazycat.manatee at gmail.com Tue Dec 2 06:58:31 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue Dec 2 06:53:51 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> <1228214680.10115.154.camel@localhost> Message-ID: <874p1mdc0o.fsf@debian.domain> Hi Dunca, Duncan Coutts writes: > On Tue, 2008-12-02 at 15:48 +0800, Andy Stewart wrote: > >> When i ./configure gtk2hs souce code, i will got below information: >> >> ,---- >> | * The following packages will be built: >> | * >> | * glib : yes >> | * gtk : yes >> | * glade : no >> | * cairo : yes >> | * svgcairo : no >> | * gtkglext : no >> | * gconf : no >> | * sourceview : no >> | * mozembed : no >> | * soegtk : yes >> | * gnomevfs : no >> | * gstreamer : no >> | * documentation : no >> `---- >> >> So i want to ask, what libraries need to install for support full >> gtk2hs? > > Those names are the names of the Haskell components/packages. All of > them (except soegtk) are wrappers for C libraries with similar names. So > you need to install the system packages that contain the development > files for those C libraries. For example the system package for glib > might be called something like "glib-dev" or "glib-devel". On some > systems they also have more numbers in like "glib2-devel" or be prefixed > with "lib", like "libglib-dev". > > You almost certainly have the runtime files for all these packages > installed already, so it's only the "dev"/"devel" variants that you need > to install. > > Duncan I have install GHC 6.10.1 and install those debian packages for predepend for gtk2hs: ,---- | libglade2-dev | libgtksourceview-dev | libgconf2-dev | librsvg2-dev | libgstreamer-plugins-base0.10-dev | libgstreamer0.10-dev | libgtkglext1-dev | libgnomevfs2-dev | xulrunner-dev `---- And i use darcs version of gtk2hs, when i ./configure, i got below information: ,---- | * The following packages will be built: | * | * glib : yes | * gtk : yes | * gio : yes | * glade : yes | * cairo : yes | * svgcairo : yes | * gtkglext : yes | * gconf : yes | * sourceview : yes | * mozembed : yes | * soegtk : yes | * gnomevfs : yes | * gstreamer : yes | * documentation : no | * `---- But when i "make", i got below error information: ,---- | glib/System/Glib.hs:13:0: | Failed to load interface for `System.Glib.UTFString': | Use -v to see a list of the files searched for. | make[1]: *** [glib/System/Glib.o] error 1 `---- So can you help me? Is i missing something? Thank you very much! -- Andy From duncan.coutts at worc.ox.ac.uk Tue Dec 2 07:18:55 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 2 07:12:35 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 In-Reply-To: <874p1mdc0o.fsf@debian.domain> References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> <1228214680.10115.154.camel@localhost> <874p1mdc0o.fsf@debian.domain> Message-ID: <1228220335.10115.157.camel@localhost> On Tue, 2008-12-02 at 19:58 +0800, Andy Stewart wrote: > Hi Dunca, > > Duncan Coutts writes: > And i use darcs version of gtk2hs, > when i ./configure, i got below information: > But when i "make", i got below error information: > > ,---- > | glib/System/Glib.hs:13:0: > | Failed to load interface for `System.Glib.UTFString': > | Use -v to see a list of the files searched for. > | make[1]: *** [glib/System/Glib.o] error 1 > `---- Usually this is not the first thing to go wrong, but for some reason make does not stop immediately. Check further up in the build log for the first error. The best place to get help on this is the gtk2hs-users mailing list https://lists.sourceforge.net/lists/listinfo/gtk2hs-users Duncan From haskell at list.mightyreason.com Tue Dec 2 07:39:13 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Dec 2 07:32:48 2008 Subject: [Haskell-cafe] Re: The Knight's Tour: solutions please In-Reply-To: <20081202083037.74165AB0F@Adric.metnet.fnmoc.navy.mil> References: <20081202083037.74165AB0F@Adric.metnet.fnmoc.navy.mil> Message-ID: <49352C71.70609@list.mightyreason.com> Hmmm... it seems that n=63 is a special case. oleg@okmij.org wrote: > Yes, there is a solution for n=99 and for n=100 for that matter -- > which can be found under one second. I only had to make a trivial > modification to the previously posted code > >> tour n k s b | k > n*n = return b >> | otherwise = do next <- (foldr mplus mzero).map return $ successors n b s >> tour n (k+1) next $ insrt next k b > > I replaced foldl1 mplus with foldr mplus zero. > The old version sees no solution to n=63 quite quickly: > time nice ./fromwiki-63 63 > fromwiki-63: Prelude.foldl1: empty list > > real 0m0.285s > user 0m0.172s > sys 0m0.026s The version with the 'tour' given above does not halt after running up to 0.4 GB of RAM, so I killed it. Though having no solution may be tied to starting in the corner. -- Chris From briqueabraque at yahoo.com Tue Dec 2 07:42:47 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Tue Dec 2 07:36:37 2008 Subject: [Haskell-cafe] Sugestion for a basic Utf8 type. Message-ID: Hi, I would like to sugest a new basic type in Haskell. What if we had something like this (with any other quoting character): ?Je ne parle pas fran?ais. Meu nome ? Maur?cio. ?Hablas espa?ol?? This would be of type Utf8. I think now it is not a bad idea, since Haskell source code is supposed to be utf-8. The internal representation of this datatype would be a null terminated utf-8 byte vector. No standard operations would be defined on that type, i.e., it would be a ?communication standard? between everybody, but module writers could develop different basic usage based on operations on them using Foreign. (I think it would be dificult to set default operations, since there are so many things you can do with utf-8.) Pros: * There would be no doubt you can use utf-8 when using this, since there's no conversion involved. * Cleaner code on utf8 operations, maybe. There are many utf8 modules today with different goals in mind, I thing it would be nice if they could share this common basic type and a common underline implementation. Cons: * Probably, many. I have no deep understanding of Haskell. Thanks for your attention, Maur?cio From Alistair.Bayley at invesco.com Tue Dec 2 08:32:15 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Tue Dec 2 08:25:40 2008 Subject: [Haskell-cafe] Sugestion for a basic Utf8 type. In-Reply-To: References: Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E974B@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Mauricio > > I would like to sugest a new basic type in Haskell. What if we had > something like this (with any other quoting character): > > ?Je ne parle pas fran?ais. Meu nome ? Maur?cio. ?Hablas espa?ol?? > > This would be of type Utf8. I think now it is not a bad idea, > since Haskell source code is supposed to be utf-8. The internal > representation of this datatype would be a null terminated utf-8 > byte vector. ... Stream fusion on Haskell Unicode strings - Tom Harper http://www.wellquite.org/non-blog/AngloHaskell2008/tom%20harper.pdf I don't know what it's status is. The original implementation used UTF16 rather than UTF8. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From jules at jellybean.co.uk Tue Dec 2 08:34:45 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Tue Dec 2 08:28:10 2008 Subject: [Haskell-cafe] Compilers In-Reply-To: <20081129132903.GE31753@sliver.repetae.net> References: <20081124042513.GA23604@scytale.galois.com> <492DBE9E.70701@btinternet.com> <492DC605.4030602@btinternet.com> <62A837ED-079C-4E15-8863-75AFCDA4BF28@cs.otago.ac.nz> <20081129033017.GB31753@sliver.repetae.net> <20081129132903.GE31753@sliver.repetae.net> Message-ID: <49353975.3010507@jellybean.co.uk> John Meacham wrote: > I never was opposed to a cabal 'target' for jhc. I have 'make dist' > 'make dist-rpm' and hopefully 'make msi' soon, adding a 'make > dist-hackage' alongside is not a bad thing, however, it is if it > complicates the standard build or comes to dominate development effort > or can't be done without duplication of functionality. My understanding is that you can have a .cabal file which merely specifies the dependency information and metadata, but delegates all the actual building to your existing configure and make infrastructure. It could then be entirely ignored (by someone who chose to type ./configure && make) but it would still work for someone who wanted to use cabal (using the metadata to get any dependencies, and then thereafter using the make-based build). Is this not a good path for a project like JHC? Jules From jules at jellybean.co.uk Tue Dec 2 08:34:52 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Tue Dec 2 08:28:17 2008 Subject: [Haskell-cafe] Compilers In-Reply-To: <20081129132903.GE31753@sliver.repetae.net> References: <20081124042513.GA23604@scytale.galois.com> <492DBE9E.70701@btinternet.com> <492DC605.4030602@btinternet.com> <62A837ED-079C-4E15-8863-75AFCDA4BF28@cs.otago.ac.nz> <20081129033017.GB31753@sliver.repetae.net> <20081129132903.GE31753@sliver.repetae.net> Message-ID: <4935397C.6070703@jellybean.co.uk> John Meacham wrote: > I never was opposed to a cabal 'target' for jhc. I have 'make dist' > 'make dist-rpm' and hopefully 'make msi' soon, adding a 'make > dist-hackage' alongside is not a bad thing, however, it is if it > complicates the standard build or comes to dominate development effort > or can't be done without duplication of functionality. My understanding is that you can have a .cabal file which merely specifies the dependency information and metadata, but delegates all the actual building to your existing configure and make infrastructure. It could then be entirely ignored (by someone who chose to type ./configure && make) but it would still work for someone who wanted to use cabal (using the metadata to get any dependencies, and then thereafter using the make-based build). Is this not a good path for a project like JHC? Jules From leimy2k at gmail.com Tue Dec 2 09:48:00 2008 From: leimy2k at gmail.com (David Leimbach) Date: Tue Dec 2 09:41:26 2008 Subject: [Haskell-cafe] GHC on Fedora 10 - getMBlock: mmap: Permission denied In-Reply-To: References: Message-ID: <3e1162e60812020648x556b53a0n3cb4659f3ca6883d@mail.gmail.com> Did you try turning off SELinux to check? 2008/12/2 Fraser Wilson > Hi all, > > Has anybody seen this? I thought it might be an SELinux thing, but then I > wouldn't expect GHC or darcs to run. Audley is a fairly simple program in > operating system feature terms, but I get the same error with anything I > build myself. > > [fraser@astroboy audley]$ ./dist/build/audley/audley > audley: internal error: getMBlock: mmap: Permission denied > (GHC version 6.8.3 for i386_unknown_linux) > Please report this as a GHC bug: > http://www.haskell.org/ghc/reportabug > Aborted > [fraser@astroboy audley]$ ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.8.3 > [fraser@astroboy audley]$ cat /proc/version > Linux version 2.6.27-0.352.rc7.git1.fc10.i686 ( > mockbuild@x86-5.fedora.phx.redhat.com) (gcc version 4.3.2 20080917 (Red > Hat 4.3.2-4) (GCC) ) #1 SMP Tue Sep 23 21:26:04 EDT 2008 > [fraser@astroboy audley]$ > > cheers, > Fraser. > > -- > http://thewhitelion.org/mysister > > _______________________________________________ > 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/20081202/aaf95c7a/attachment.htm From duncan.coutts at worc.ox.ac.uk Tue Dec 2 09:48:45 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 2 09:42:14 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 In-Reply-To: References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> <1228214680.10115.154.camel@localhost> Message-ID: <1228229325.10115.163.camel@localhost> On Tue, 2008-12-02 at 11:01 +0000, Colin Paul Adams wrote: > >>>>> "Duncan" == Duncan Coutts writes: > > >> gstreamer > > Duncan> Those names are the names of the Haskell > Duncan> components/packages. All of them (except soegtk) are > Duncan> wrappers for C libraries with similar names. So you need > Duncan> to install the system packages that contain the > Duncan> development files for those C libraries. For example the > Duncan> system package for glib might be called something like > Duncan> "glib-dev" or "glib-devel". On some systems they also have > Duncan> more numbers in like "glib2-devel" or be prefixed with > Duncan> "lib", like "libglib-dev". > > I have gstreamer-devel installed, but configure doesn't find it. Specifically you need the native package that provides the file gstreamer-0.10.pc Eg on my system I've got the file: /usr/lib/pkgconfig/gstreamer-0.10.pc If you run ./configure --enable-gstreamer it'll tell you something similar. Duncan From blancolioni at gmail.com Tue Dec 2 10:34:19 2008 From: blancolioni at gmail.com (Fraser Wilson) Date: Tue Dec 2 10:27:46 2008 Subject: [Haskell-cafe] GHC on Fedora 10 - getMBlock: mmap: Permission denied In-Reply-To: <3e1162e60812020648x556b53a0n3cb4659f3ca6883d@mail.gmail.com> References: <3e1162e60812020648x556b53a0n3cb4659f3ca6883d@mail.gmail.com> Message-ID: Why didn't that occur to me? I should get more sleep. Thanks for the tip. Now I know that it definitely is SELinux, a system I understand not at all, I presume the problem is in these context things ... ghc has system_u and bin_t, while audley has unconfined_u and file_t. Time to go poking about. The unconfined_u looks suspicious. cheers, Fraser. On Tue, Dec 2, 2008 at 3:48 PM, David Leimbach wrote: > Did you try turning off SELinux to check? > > 2008/12/2 Fraser Wilson > >> Hi all, >> >> Has anybody seen this? I thought it might be an SELinux thing, but then I >> wouldn't expect GHC or darcs to run. Audley is a fairly simple program in >> operating system feature terms, but I get the same error with anything I >> build myself. >> >> [fraser@astroboy audley]$ ./dist/build/audley/audley >> audley: internal error: getMBlock: mmap: Permission denied >> (GHC version 6.8.3 for i386_unknown_linux) >> Please report this as a GHC bug: >> http://www.haskell.org/ghc/reportabug >> Aborted >> [fraser@astroboy audley]$ ghc --version >> The Glorious Glasgow Haskell Compilation System, version 6.8.3 >> [fraser@astroboy audley]$ cat /proc/version >> Linux version 2.6.27-0.352.rc7.git1.fc10.i686 ( >> mockbuild@x86-5.fedora.phx.redhat.com) (gcc version 4.3.2 20080917 (Red >> Hat 4.3.2-4) (GCC) ) #1 SMP Tue Sep 23 21:26:04 EDT 2008 >> [fraser@astroboy audley]$ >> >> cheers, >> Fraser. >> >> -- >> http://thewhitelion.org/mysister >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -- http://thewhitelion.org/mysister -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/a6a64266/attachment.htm From bulat.ziganshin at gmail.com Tue Dec 2 10:42:10 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Dec 2 10:40:22 2008 Subject: [Haskell-cafe] GHC on Fedora 10 - getMBlock: mmap: Permission denied In-Reply-To: References: <3e1162e60812020648x556b53a0n3cb4659f3ca6883d@mail.gmail.com> Message-ID: <714866820.20081202184210@gmail.com> Hello Fraser, Tuesday, December 2, 2008, 6:34:19 PM, you wrote: search in GHC tracker: afair there was some SELinux-releated report > Why didn't that occur to me?? I should get more sleep. Thanks for > the tip.? Now I know that it definitely is SELinux, a system I > understand not at all, I presume the problem is in these context > things ... ghc has system_u and bin_t, while audley has unconfined_u > and file_t.? Time to go poking about.? The unconfined_u looks suspicious. > > cheers, > Fraser. > On Tue, Dec 2, 2008 at 3:48 PM, David Leimbach wrote: > Did you try turning off SELinux to check? ? > 2008/12/2 Fraser Wilson > > Hi all, > Has anybody seen this?? I thought it might be an SELinux thing, but > then I wouldn't expect GHC or darcs to run.? Audley is a fairly > simple program in operating system feature terms, but I get the same > error with anything I build myself. > > [fraser@astroboy audley]$ ./dist/build/audley/audley > audley: internal error: getMBlock: mmap: Permission denied > ??? (GHC version 6.8.3 for i386_unknown_linux) > ??? Please report this as a GHC bug:? > http://www.haskell.org/ghc/reportabug > Aborted > [fraser@astroboy audley]$ ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.8.3 > [fraser@astroboy audley]$ cat /proc/version > Linux version 2.6.27-0.352.rc7.git1.fc10.i686 > (mockbuild@x86-5.fedora.phx.redhat.com) (gcc version 4.3.2 20080917 > (Red Hat 4.3.2-4) (GCC) ) #1 SMP Tue Sep 23 21:26:04 EDT 2008 > [fraser@astroboy audley]$ > cheers, > Fraser. > -- > http://thewhitelion.org/mysister > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From blancolioni at gmail.com Tue Dec 2 11:05:16 2008 From: blancolioni at gmail.com (Fraser Wilson) Date: Tue Dec 2 10:58:42 2008 Subject: [Haskell-cafe] GHC on Fedora 10 - getMBlock: mmap: Permission denied In-Reply-To: <714866820.20081202184210@gmail.com> References: <3e1162e60812020648x556b53a0n3cb4659f3ca6883d@mail.gmail.com> <714866820.20081202184210@gmail.com> Message-ID: Thanks, Bulat, ticket #738 appears to be it. It was fixed in September, but I guess it hasn't made it to yum yet, although there's a work-around with permissions and so forth. cheers, Fraser. On Tue, Dec 2, 2008 at 4:42 PM, Bulat Ziganshin wrote: > Hello Fraser, > > Tuesday, December 2, 2008, 6:34:19 PM, you wrote: > > search in GHC tracker: afair there was some SELinux-releated report > > > Why didn't that occur to me? I should get more sleep. Thanks for > > the tip. Now I know that it definitely is SELinux, a system I > > understand not at all, I presume the problem is in these context > > things ... ghc has system_u and bin_t, while audley has unconfined_u > > and file_t. Time to go poking about. The unconfined_u looks suspicious. > > > > cheers, > > Fraser. > > > On Tue, Dec 2, 2008 at 3:48 PM, David Leimbach > wrote: > > Did you try turning off SELinux to check? > > > 2008/12/2 Fraser Wilson > > > > Hi all, > > > Has anybody seen this? I thought it might be an SELinux thing, but > > then I wouldn't expect GHC or darcs to run. Audley is a fairly > > simple program in operating system feature terms, but I get the same > > error with anything I build myself. > > > > [fraser@astroboy audley]$ ./dist/build/audley/audley > > audley: internal error: getMBlock: mmap: Permission denied > > (GHC version 6.8.3 for i386_unknown_linux) > > Please report this as a GHC bug: > > http://www.haskell.org/ghc/reportabug > > Aborted > > [fraser@astroboy audley]$ ghc --version > > The Glorious Glasgow Haskell Compilation System, version 6.8.3 > > [fraser@astroboy audley]$ cat /proc/version > > Linux version 2.6.27-0.352.rc7.git1.fc10.i686 > > (mockbuild@x86-5.fedora.phx.redhat.com) (gcc version 4.3.2 20080917 > > (Red Hat 4.3.2-4) (GCC) ) #1 SMP Tue Sep 23 21:26:04 EDT 2008 > > [fraser@astroboy audley]$ > > > cheers, > > Fraser. > > > -- > > http://thewhitelion.org/mysister > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > > > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -- http://thewhitelion.org/mysister -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/32c79f82/attachment.htm From jason.dusek at gmail.com Tue Dec 2 11:16:50 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Dec 2 11:10:14 2008 Subject: [Haskell-cafe] Sugestion for a basic Utf8 type. In-Reply-To: References: Message-ID: <42784f260812020816p1fec8b74o234a75e7465dfc77@mail.gmail.com> Unlike native Strings, this would have the potential for a runtime parse error at every character. -- _jsn From briqueabraque at yahoo.com Tue Dec 2 11:50:03 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Tue Dec 2 11:43:39 2008 Subject: [Haskell-cafe] Re: Sugestion for a basic Utf8 type. In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA9049E974B@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E974B@GBLONXMB02.corp.amvescap.net> Message-ID: >> I would like to sugest a new basic type in Haskell. What if we had >> something like this (with any other quoting character): >> >> ?Je ne parle pas fran?ais. (...) ?Hablas espa?ol?? >> >> This would be of type Utf8. I think now it is not a bad idea, >> since Haskell source code is supposed to be utf-8. The internal >> representation of this datatype would be a null terminated utf-8 >> byte vector. ... > Stream fusion on Haskell Unicode strings - Tom Harper > http://www.wellquite.org/non-blog/AngloHaskell2008/tom%20harper.pdf > (...) Actually, what I suggest is quite different, in points I see as worthwhile: * His focus is on speed and memory, my goal is more elegant and safe code. * His approach consolidates Prelude. My approach allows complete elimination of Prelude. If we had a Utf8 basic type, we could have modules with many different basic types, and many different ideas on how to 'read ?something? :: '. In the future, we could write a module to implement some sort of not yet invented numeral type, which other module would allow to be readed from Chinese kanji. * He wants to preserve many properties of [Char]. I think Utf8 type should have no standard properties at all. See next argument on why this would avoid some unsafe code. * He insists on the idea of text as something over char. Well, I'm probably alone there, but I think this was nice, but today we could have better approachs. Except for source code, text is a block of information, not a sequence of anything. I explicitly would like a type we could not map over, because we can't do that ? text is built from so many things, there's no basic unit we can apply functions to. Even something like "printing of a table of all characters and their unicode numbers" is impossible, since a lot of unicode is not printable. "Are these blocks of text equal?" also do not work like that, since different sets of bytes can have the same meaning. If you want some piece of text to obey specific properties, you should have to extract it to a proper type. Sorry if this is insane for some reason. Thanks, Maur?cio From claus.reinke at talk21.com Tue Dec 2 11:55:35 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Dec 2 11:49:03 2008 Subject: [Haskell-cafe] Re: [Haskell] GHC 6.10 and OpenGL References: <856033f20811221231n6cfdb3ew46835f9636ceed68@mail.gmail.com><20081122203441.GG17052@scytale.galois.com><856033f20811222034r51c8db57qd76881a8b4ee005b@mail.gmail.com><1227433045.7124.267.camel@localhost> <1227445392.7124.294.camel@localhost> Message-ID: <48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> I finally got round to trying cabal-install with OpenGL/GLUT, using a freshly built ghc head, a cygwin bash, and >> > http://haskell.org/~duncan/cabal/cabal.exe cabal-install version 0.6.0 using version 1.6.0.1 of the Cabal library >> > Yes, building it requires mingw/msys, but with it cabal install opengl >> > really does work (I've tried it). cabal.exe opengl glut The first oddity was in the dependency resolution phase, where cabal.exe insists on installing array-0.2.0.0 and containers-0.2.0.0, which are already installed. Ignoring that, the build went through without any apparent hitch. Here is the relevant part of the build log: package: GLUT-2.1.1.2 os: windows arch: i386 compiler: ghc-6.11.20081202 client: cabal-install-0.6.0 flags: split-base dependencies: OpenGL-2.2.1.1 array-0.2.0.0 base-3.0.3.0 containers-0.2.0.0 install-outcome: InstallOk docs-outcome: NotTried tests-outcome: NotTried package: OpenGL-2.2.1.1 os: windows arch: i386 compiler: ghc-6.11.20081202 client: cabal-install-0.6.0 flags: dependencies: base-3.0.3.0 install-outcome: InstallOk docs-outcome: NotTried tests-outcome: NotTried package: array-0.2.0.0 os: windows arch: i386 compiler: ghc-6.11.20081202 client: cabal-install-0.6.0 flags: dependencies: base-4.0.0.0 syb-0.1.0.0 install-outcome: InstallOk docs-outcome: NotTried tests-outcome: NotTried package: containers-0.2.0.0 os: windows arch: i386 compiler: ghc-6.11.20081202 client: cabal-install-0.6.0 flags: dependencies: array-0.2.0.0 base-4.0.0.0 install-outcome: InstallOk docs-outcome: NotTried tests-outcome: NotTried But when I actually try to build anything using (yes, I know the explicit package flags aren't needed with --make) ghc --make -package OpenGL -package GLUT something.hs I get nothing but undefined references in the linking phase. C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202/libHSGLUT-2.1.1.2.a(Window.o):fake: (.text+0x15): undefined reference to `glutWarpPointer' C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202/libHSGLUT-2.1.1.2.a(Window.o):fake:(.text+0x3d): undefined reference to `glutReshapeWindow' C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202/libHSGLUT-2.1.1.2.a(Window.o):fake:(.text+0x65): undefined reference to `glutPositionWindow' .. >> The problem is that this places an additional barrier on distribution: >> Haskell OpenGL authors cannot simply distribute their Haskell code, >> because many other Haskellers will not be able to get it to work: > > For the rest of the issues I think the proper solution is the platform > installer which would include cabal.exe and a pre-built OpenGL. > > We could probably do better for packages that need mingw. Most of them > record this information in the build-type: Configure, so perhaps > cabal.exe should check if sh.exe is present before trying to build > packages that need it. If that sounds sensible then lets file a ticket > so we don't forget. 'build-type: Configure' just means that configure is needed, but says nothing about whether that is the MSys/Cygwin/.. variant of the toolchain, or which version. That would be okay if the variant/version didn't matter, but that is rarely the case. Why not have a shallow facade cabal-package for the native packages/ tools? Then cabal packages could depend on precise versions of those facade packages for windows builds, and users would know exactly what they need (and whether they have it, if the test for MSys/configure is in the msys-configure package, or where to get it, if that is documented in the facade packages; the same trick should work for other tool dependencies, such as happy/alex/..; possibly even for non-haskell library dependencies for API FFI bindings: depend on the msys-configure package, run configure to see whether library is installed, register outcome as a cabal facade package with how-to-get-it information). Btw, is the format for the cabal config file documented somewhere? I though I had set documentation to True. Claus From allbery at ece.cmu.edu Tue Dec 2 03:02:02 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Dec 2 11:54:07 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 In-Reply-To: <87d4gbc909.fsf@debian.domain> References: <878wqzxe7z.fsf@debian.domain> <87d4gbc909.fsf@debian.domain> Message-ID: On 2008 Dec 2, at 2:48, Andy Stewart wrote: > ,---- > | * The following packages will be built: > | * > | * glib : yes > | * gtk : yes > | * glade : no > | * cairo : yes > | * svgcairo : no > | * gtkglext : no > | * gconf : no > | * sourceview : no > | * mozembed : no > | * soegtk : yes > | * gnomevfs : no > | * gstreamer : no > | * documentation : no > `---- > > So i want to ask, what libraries need to install for support full > gtk2hs? You need the native development libraries for all the listed libraries. On Linux a first cut is to check for (rpm or apt as appropriate) packages named (something)-dev or (something)-devel, e.g. glade-dev. (Some of them will be versioned, for example gconf2- devel.) The Haskell libraries are wrappers for the native libraries. On OSX there's the additional complication that there are both native (new, not well tested, not very complete) and X11 (uglier but well tested) versions of many of these, and the two don't mix. -- 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 duncan.coutts at worc.ox.ac.uk Tue Dec 2 12:23:44 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 2 12:17:15 2008 Subject: [Haskell-cafe] Re: [Haskell] GHC 6.10 and OpenGL In-Reply-To: <48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> References: <856033f20811221231n6cfdb3ew46835f9636ceed68@mail.gmail.com> <20081122203441.GG17052@scytale.galois.com> <856033f20811222034r51c8db57qd76881a8b4ee005b@mail.gmail.com> <1227433045.7124.267.camel@localhost> <1227445392.7124.294.camel@localhost> <48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> Message-ID: <1228238624.10115.176.camel@localhost> On Tue, 2008-12-02 at 16:55 +0000, Claus Reinke wrote: > But when I actually try to build anything using (yes, I know the explicit > package flags aren't needed with --make) > > ghc --make -package OpenGL -package GLUT something.hs > > I get nothing but undefined references in the linking phase. > > C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202/libHSGLUT-2.1.1.2.a(Window.o):fake: > (.text+0x15): undefined reference to `glutWarpPointer' Does ghc-pkg describe OpenGL tell you that the package needs some gl C lib? Eg "ld-options: -lGLU -lGL -lm" When you ghc --make -v, is it actually linking to a gl C lib? > Btw, is the format for the cabal config file documented somewhere? > I though I had set documentation to True. At the moment only in the config file itself. It lists all the fields (commented out) and where there are default values it lists those too. Duncan From jason.dusek at gmail.com Tue Dec 2 12:27:43 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Dec 2 12:21:07 2008 Subject: [Haskell-cafe] Re: Sugestion for a basic Utf8 type. In-Reply-To: References: <125EACD0CAE4D24ABDB4D148C4593DA9049E974B@GBLONXMB02.corp.amvescap.net> Message-ID: <42784f260812020927x8a52cb3la7970b54210f924c@mail.gmail.com> So this proposal is more than a UTF8 type, since it encompasses a move away from text as lists. What interfaces would we have to text in this proposal? -- _jsn From info at tobias-kraentzer.de Tue Dec 2 12:49:56 2008 From: info at tobias-kraentzer.de (=?ISO-8859-1?Q?Tobias_Kr=E4ntzer?=) Date: Tue Dec 2 12:43:21 2008 Subject: [Haskell-cafe] Problem building HXQ on Mac OS 10.5.5 Message-ID: <6E438D44-73F6-4ACD-9BB8-35BEEC3FD836@tobias-kraentzer.de> Hi, I'm new to haskell and wonted to start tinkering a bit with this language, specifically with HXQ. I have installed ghc with macports. Now while building HXQ I get the following error: Main.hs:20:9: Not in scope: type constructor or class `C.SomeException' Unfortunately I'm also new to Mac OS X. Before I developed on Linux. It would be great, if someone could give me a hint. Thanks, Tobias PS: Below the details -- ~$ cabal install hxq Resolving dependencies... 'HXQ-0.11.0' is cached. Configuring HXQ-0.11.0... Preprocessing library HXQ-0.11.0... Preprocessing executables for HXQ-0.11.0... Building HXQ-0.11.0... . . . Loading package haskell98 ... linking ... done. [20 of 21] Compiling Text.XML.HXQ.XQuery ( src/Text/XML/HXQ/XQuery.hs, dist/build/xquery/xquery-tmp/Text/XML/HXQ/XQuery.o ) [21 of 21] Compiling Main ( Main.hs, dist/build/xquery/ xquery-tmp/Main.o ) Main.hs:20:9: Not in scope: type constructor or class `C.SomeException' cabal: Error: some packages failed to install: HXQ-0.11.0 failed during the building phase. The exception was: exit: ExitFailure 1 -- ~$ ghc-pkg list /opt/local/lib/ghc-6.10.1/./package.conf: Cabal-1.6.0.1, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.0, base-4.0.0.0, bytestring-0.9.1.4, containers-0.2.0.0, directory-1.0.0.2, (dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), editline-0.2.1.0, filepath-1.1.0.1, (ghc-6.10.1), ghc-prim-0.1.0.0, haddock-2.3.0, haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.2, html-1.0.1.2, integer-0.1.0.0, mtl-1.1.0.2, network-2.2.0.1, old-locale-1.0.0.1, old-time-1.0.0.1, packedstring-0.1.0.1, parallel-1.1.0.0, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.0, random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, stm-2.1.1.2, syb-0.1.0.0, template-haskell-2.3.0.0, time-1.1.2.2, unix-2.3.1.0, xhtml-3000.2.0.1 /Users/tobias/.ghc/i386-darwin-6.10.1/package.conf: readline-1.0.1.0 -- Tobias Kr?ntzer info@tobias-kraentzer.de From claus.reinke at talk21.com Tue Dec 2 13:04:41 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Dec 2 12:58:08 2008 Subject: [Haskell-cafe] Re: [Haskell] GHC 6.10 and OpenGL References: <856033f20811221231n6cfdb3ew46835f9636ceed68@mail.gmail.com><20081122203441.GG17052@scytale.galois.com><856033f20811222034r51c8db57qd76881a8b4ee005b@mail.gmail.com><1227433045.7124.267.camel@localhost><1227445392.7124.294.camel@localhost><48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> <1228238624.10115.176.camel@localhost> Message-ID: >> ghc --make -package OpenGL -package GLUT something.hs >> I get nothing but undefined references in the linking phase. >> C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202/libHSGLUT-2.1.1.2.a(Window.o):fake: >> (.text+0x15): undefined reference to `glutWarpPointer' > > Does ghc-pkg describe OpenGL tell you that the package needs some gl C > lib? Eg "ld-options: -lGLU -lGL -lm" Yes: $ ghc-pkg field OpenGL import-dirs,library-dirs,hs-libraries,include-dirs,includes,cc-options,ld-options import-dirs: "C:\\Program Files\\Haskell\\OpenGL-2.2.1.1\\ghc-6.11.20081202" library-dirs: "C:\\Program Files\\Haskell\\OpenGL-2.2.1.1\\ghc-6.11.20081202" hs-libraries: HSOpenGL-2.2.1.1 include-dirs: "C:\\Program Files\\Haskell\\OpenGL-2.2.1.1\\ghc-6.11.20081202\\include" includes: HsOpenGL.h cc-options: ld-options: -lglu32 -lopengl32 $ ghc-pkg field GLUT import-dirs,library-dirs,hs-libraries,include-dirs,includes,cc-options,ld-options import-dirs: "C:\\Program Files\\Haskell\\GLUT-2.1.1.2\\ghc-6.11.20081202" library-dirs: "C:\\Program Files\\Haskell\\GLUT-2.1.1.2\\ghc-6.11.20081202" hs-libraries: HSGLUT-2.1.1.2 include-dirs: "C:\\Program Files\\Haskell\\GLUT-2.1.1.2\\ghc-6.11.20081202\\include" includes: HsGLUT.h cc-options: ld-options: -lglut32 -lglu32 -lopengl32 > When you ghc --make -v, is it actually linking to a gl C lib? It looks that way: *** Linker: (slightly reformated) C:\ghc\ghc-6.11.20081202\gcc -BC:\ghc\ghc-6.11.20081202\gcc-lib/ -IC:\ghc\ghc-6.11.20081202\include/mingw/ -v -o Lift.exe -DDONT_WANT_WIN32_DLL_SUPPORT obj\Main.o obj\FunWorlds.o obj\Scene.o obj\Behavior.o C:\DOCUME~1\cr3\LOCALS~1\Temp\/ghc3144_0/ghc3144_0.o -LC:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202 -LC:\Program Files\Haskell\containers-0.2.0.0\ghc-6.11.20081202 -LC:\Program Files\Haskell\OpenGL-2.2.1.1\ghc-6.11.20081202 -LC:\ghc\ghc-6.11.20081202\haskell98-1.0.1.0 -LC:\ghc\ghc-6.11.20081202\random-1.0.0.1 -LC:\ghc\ghc-6.11.20081202\process-1.0.1.1 -LC:\ghc\ghc-6.11.20081202\directory-1.0.0.2 -LC:\ghc\ghc-6.11.20081202\old-time-1.0.0.1 -LC:\ghc\ghc-6.11.20081202\old-locale-1.0.0.1 -LC:\ghc\ghc-6.11.20081202\filepath-1.1.0.1 -LC:\ghc\ghc-6.11.20081202\Win32-2.2.0.0 -LC:\ghc\ghc-6.11.20081202\bytestring-0.9.1.4 -LC:\Program Files\Haskell\array-0.2.0.0\ghc-6.11.20081202 -LC:\ghc\ghc-6.11.20081202\base-3.0.3.0 -LC:\ghc\ghc-6.11.20081202\syb-0.1.0.0 -LC:\ghc\ghc-6.11.20081202\base-4.0.0.0 -LC:\ghc\ghc-6.11.20081202\integer-0.1.0.0 -LC:\ghc\ghc-6.11.20081202\ghc-prim-0.1.0.0 -LC:\ghc\ghc-6.11.20081202 -LC:\ghc\ghc-6.11.20081202/gcc-lib -lHSGLUT-2.1.1.2 -lglut32 -lglu32 -lopengl32 -lHScontainers-0.2.0.0 -lHSOpenGL-2.2.1.1 -lglu32 -lopengl32 -lHShaskell98-1.0.1.0 -lHSrandom-1.0.0.1 -lHSprocess-1.0.1.1 -lHSdirectory-1.0.0.2 -lHSold-time-1.0.0.1 -lHSold-locale-1.0.0.1 -lHSfilepath-1.1.0.1 -lHSWin32-2.2.0.0 -luser32 -lgdi32 -lwinmm -lkernel32 -ladvapi32 -lHSbytestring-0.9.1.4 -lHSarray-0.2.0.0 -lHSbase-3.0.3.0 -lHSsyb-0.1.0.0 -lHSbase-4.0.0.0 -lwsock32 -lmsvcrt -lkernel32 -luser32 -lshell32 -lHSinteger-0.1.0.0 -lHSghc-prim-0.1.0.0 -lHSrts -lm -lgmp -lwsock32 -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOBase_stackOverflow_closure -u _base_GHCziIOBase_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOBase_blockedOnDeadMVar_closure -u _base_GHCziIOBase_blockedIndefinitely_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConc_ensureIOManagerIsRunning_closure -u _base_GHCziConc_runSparks_closure -lHSffi $ ls C:/ghc/ghc-6.11.20081202/gcc-lib/*gl* C:/ghc/ghc-6.11.20081202/gcc-lib/CRT_noglob.o C:/ghc/ghc-6.11.20081202/gcc-lib/libglut.a C:/ghc/ghc-6.11.20081202/gcc-lib/libglaux.a C:/ghc/ghc-6.11.20081202/gcc-lib/libglut32.a C:/ghc/ghc-6.11.20081202/gcc-lib/libglu32.a C:/ghc/ghc-6.11.20081202/gcc-lib/libopengl32.a >> Btw, is the format for the cabal config file documented somewhere? >> I though I had set documentation to True. > > At the moment only in the config file itself. It lists all the fields > (commented out) and where there are default values it lists those too. ah, I wasn't sure whether those '--' were meant to indicate options or commenting (a comment in the first line might make usage unambiguous?-) Claus From briqueabraque at yahoo.com Tue Dec 2 13:17:36 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Tue Dec 2 13:11:12 2008 Subject: [Haskell-cafe] Re: Sugestion for a basic Utf8 type. In-Reply-To: <42784f260812020927x8a52cb3la7970b54210f924c@mail.gmail.com> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E974B@GBLONXMB02.corp.amvescap.net> <42784f260812020927x8a52cb3la7970b54210f924c@mail.gmail.com> Message-ID: > So this proposal is more than a UTF8 type, since it > encompasses a move away from text as lists. What interfaces > would we have to text in this proposal? > Normal users would import modules with specific interfaces, like functions or instances. One possible such module would be Streams like those sugested in the previous article. Others could offer functionality I don't know of -- maybe there's some usefull interface for japanese or greek users we (non japanese or greek) don't imagine. My first attempt would be PortugueseText, with a type that could only be built after Portuguese "primitives" or read from Utf8 with possible errors, and convert to Utf8 of course. That type would always convert to Utf8 with correct diacriticals, and sort with the latest Portuguese agreements. Mapping over syllables could be allowed, that makes sense in syllabic languages. Quotes, questions, parenthesis etc. could be done with functions like 'quote ?Ser ou n?o ser?'. Other could be SimpleEnglishTextAsList, that could offer something close to what we have today, with functions for uppercasing, lowercasing and well behaved (non ambiguous) sorting. Writers of very basic modules would have to touch Utf8 using Foreign. So, maybe the only standard interface would be a (ForeignPtr?) pointer to a null terminated block of memory. This would make Foreign a new Prelude, maybe. In the end, this is just a basic block of memory that we can fill with utf-8 text, and that serves as a common denominador. Best, Maur?cio From bertram.felgenhauer at googlemail.com Tue Dec 2 14:26:50 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Tue Dec 2 14:20:20 2008 Subject: [Haskell-cafe] Re: The Knight's Tour: solutions please In-Reply-To: <49352C71.70609@list.mightyreason.com> References: <20081202083037.74165AB0F@Adric.metnet.fnmoc.navy.mil> <49352C71.70609@list.mightyreason.com> Message-ID: <20081202192650.GA7819@zombie.inf.tu-dresden.de> ChrisK wrote: > Hmmm... it seems that n=63 is a special case. > > oleg@okmij.org wrote: >> Yes, there is a solution for n=99 and for n=100 for that matter -- >> which can be found under one second. I only had to make a trivial >> modification to the previously posted code >>> tour n k s b | k > n*n = return b >>> | otherwise = do next <- (foldr mplus mzero).map return $ >>> successors n b s >>> tour n (k+1) next $ insrt next k b >> I replaced foldl1 mplus with foldr mplus zero. > > The old version sees no solution to n=63 quite quickly: > >> time nice ./fromwiki-63 63 >> fromwiki-63: Prelude.foldl1: empty list >> real 0m0.285s >> user 0m0.172s >> sys 0m0.026s That's a bug. When the list of candidates is empty at that point, the program should backtrack, not terminate. In fact there are solutions for n=63. Using the first improved heuristic from my previous mail in this thread: > time ./tour2 63 1 4 143 148 211 6 229 226 241 8 553 578 571 10 551 584 573 12 549 630 643 14 547 670 665 16 545 684 679 18 543 770 765 20 541 816 867 22 539 952 995 24 537 1044 1121 26 535 1208 1231 28 533 1300 1307 30 531 494 489 32 491 404 39 34 37 ... real 0m1.750s user 0m1.564s sys 0m0.008s > The version with the 'tour' given above does not halt after running up to > 0.4 GB of RAM, so I killed it. In fact, replacing foldl1 mplus by foldr mplus mzero fixed that bug. Bertram From p3k at iki.fi Tue Dec 2 14:33:23 2008 From: p3k at iki.fi (Pekka Karjalainen) Date: Tue Dec 2 14:26:47 2008 Subject: [Haskell-cafe] Re: [Haskell] GHC 6.10 and OpenGL In-Reply-To: <48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> References: <856033f20811221231n6cfdb3ew46835f9636ceed68@mail.gmail.com> <20081122203441.GG17052@scytale.galois.com> <856033f20811222034r51c8db57qd76881a8b4ee005b@mail.gmail.com> <1227433045.7124.267.camel@localhost> <1227445392.7124.294.camel@localhost> <48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> Message-ID: <233457100812021133t35980f1am6a7fb6c9adca3e32@mail.gmail.com> On Tue, Dec 2, 2008 at 6:55 PM, Claus Reinke wrote: > I finally got round to trying cabal-install with OpenGL/GLUT, > using a freshly built ghc head, a cygwin bash, and [...] > C:\Program > Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202/libHSGLUT-2.1.1.2.a(Window.o):fake: > (.text+0x15): undefined reference to `glutWarpPointer' [...] I believe these errors are caused by the wrong calling convention being used in the Haskell bindings. This part in the configure script tests the build (host) platform: case "$host" in *-mingw32) CALLCONV=stdcall ;; *) CALLCONV=ccall ;; esac Since it doesn't test for Cygwin, you end up with the calling convention being ccall, which leads to the linker errors because of associated name mangling (you would also see run-time crashes if you managed to somehow link your program). Pekka From andrewcoppin at btinternet.com Tue Dec 2 14:44:16 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Dec 2 14:37:42 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <20081201225102.GA6243@hustlerturf.com> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> <20081201225102.GA6243@hustlerturf.com> Message-ID: <49359010.8040306@btinternet.com> John Goerzen wrote: > On Mon, Dec 01, 2008 at 09:59:24PM +0000, Andrew Coppin wrote: > >>> >> OK, now I'm puzzled. I don't remember that! :-} >> > > OK, I went back and looked at my Git logs and you're right. Wrong > Andrew. Sorry. > LOL! S'OK... > I would welcome bug reports and, even better, patches for this stuff. > > But I was pretty sure that HDBC and HDBC-ODBC in particular are > working on Windows. > OK, well how about this then: In a few weeks when I upgrade to GHC 6.10.1, I'll tell you whether it builds there. ;-) For the record, which package is the "correct" one to use? Hackage seems to have a bazillion different database packages, and I have literally no idea which ones are the currently maintained ones... Regardless, it has been my general experience that almost everything obtained from Hackage fails miserably to compile under Windows. (IIRC, one package even used a Bash script as part of the build process!) I haven't seen similar problems on Linux. (But I don't use Linux very often.) About the worst problem there was Gtk2hs being confused about some Autoconfig stuff or something... From claus.reinke at talk21.com Tue Dec 2 14:57:46 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Dec 2 14:51:17 2008 Subject: [Haskell-cafe] Re: [Haskell] GHC 6.10 and OpenGL References: <856033f20811221231n6cfdb3ew46835f9636ceed68@mail.gmail.com><20081122203441.GG17052@scytale.galois.com><856033f20811222034r51c8db57qd76881a8b4ee005b@mail.gmail.com><1227433045.7124.267.camel@localhost><1227445392.7124.294.camel@localhost><48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> <233457100812021133t35980f1am6a7fb6c9adca3e32@mail.gmail.com> Message-ID: <138178959932468CBF8B3BB702FBF48F@cr3lt> > I believe these errors are caused by the wrong calling convention > being used in the Haskell bindings. This part in the configure script > tests the build (host) platform: > > case "$host" in > *-mingw32) CALLCONV=stdcall ;; > *) CALLCONV=ccall ;; > esac > > Since it doesn't test for Cygwin, you end up with the calling > convention being ccall, which leads to the linker errors because of > associated name mangling (you would also see run-time crashes if you > managed to somehow link your program). Ah, that makes sense! And, indeed, for the archives, this workaround fixes the issue (even when building from cygwin bash): cabal install opengl glut --configure-option="--host=i386-unknown-mingw32" --reinstall Thanks, now FunWorlds can ride again!-) I suppose we could document this on the OpenGL wiki, but even better would be a fix to OpenGL's configure (apart from checking the build environment (mingw) rather than the host (cygwin here), it should ensure that the build uses exactly what configure has tested successfully) or .cabal (allways setting the --host configure option if on windows)? [cc-ed to hopengl list, since this seems to be an OpenGL-specific issue, not a general Cabal one; Cabal++ :-] Claus PS of course, a high-level interpretation of the linker errors, by cabal or by ghc, would also help in such cases (linking object code is a ghc-internal detail, we work with Haskell code!-). From mailing_list at istitutocolli.org Tue Dec 2 16:29:56 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Tue Dec 2 16:23:24 2008 Subject: [Haskell-cafe] global variables for foreign C functions In-Reply-To: <6d74b0d20812011730x212fab95oadeac0ec756015bb@mail.gmail.com> References: <20081202003924.GC21677@Andrea.Nowhere.net> <2518b95d0812011655w2585995ega1aebbdc6e0e1cde@mail.gmail.com> <6d74b0d20812011730x212fab95oadeac0ec756015bb@mail.gmail.com> Message-ID: <20081202212956.GA26844@Andrea.Nowhere.net> On Mon, Dec 01, 2008 at 05:30:33PM -0800, Judah Jacobson wrote: > You can limit the size of that stub file using: > > foreign import ccall "&progname" progname :: Ptr (Ptr CChar) > > which lets you access that global variable and write the > getters/setters in Haskell rather than C. this solves my problems quite nicely indeed, but I still cannot figure how to write a setter function that actually works. That is to say, after: newCString "new_name" >>= poke progname this: putStrLn . show =<< peekCString =<< peek progname would return "new_name", but the library, which is using "progname" to produce some debugging messages, doesn't seem to get it correctly: the original bits are gone, but instead of "new_name" I get some garbage. Thanks to everyone for the interesting and useful hints. Andrea From dmehrtash at gmail.com Tue Dec 2 17:11:53 2008 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Tue Dec 2 17:05:15 2008 Subject: [Haskell-cafe] Deriving Message-ID: What happens when a type adds driving such as: newtype SupplyT s m a = SupplyT (StateT [s] m a) deriving (Functor , Monad , MonadTrans, MonadIO) Two questions: How does the deriving implement the instance? Is there a way for me to add my own classes in the deriving? for example newtype ..... deriving( xyz) Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/da53dbd1/attachment.htm From huschi at gmx.org Tue Dec 2 17:18:09 2008 From: huschi at gmx.org (Martin Huschenbett) Date: Tue Dec 2 17:11:30 2008 Subject: [Haskell-cafe] Deriving In-Reply-To: References: Message-ID: <4935B421.1000200@gmx.org> If you use a newtype the answer to the second question is yes. Just put {-# LANGUAGE GeneralizedNewtypeDeriving #-} in the first line of your module or pass -XGeneralizedNewtypeDeriving to ghc or ghci. Daryoush Mehrtash schrieb: > What happens when a type adds driving such as: > > newtype SupplyT s m a = SupplyT (StateT [s] m a) > > deriving (Functor , Monad , MonadTrans, MonadIO) > > > Two questions: > > How does the deriving implement the instance? > > Is there a way for me to add my own classes in the deriving? for example > > newtype ..... > deriving( xyz) > > > Thanks > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Tue Dec 2 18:24:06 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 2 18:17:41 2008 Subject: [Haskell-cafe] Re: [Haskell] GHC 6.10 and OpenGL In-Reply-To: References: <856033f20811221231n6cfdb3ew46835f9636ceed68@mail.gmail.com> <20081122203441.GG17052@scytale.galois.com> <856033f20811222034r51c8db57qd76881a8b4ee005b@mail.gmail.com> <1227433045.7124.267.camel@localhost> <1227445392.7124.294.camel@localhost> <48D5B29EAB504EBAAF3B61CB460922A0@cr3lt> <1228238624.10115.176.camel@localhost> Message-ID: <1228260246.10115.198.camel@localhost> On Tue, 2008-12-02 at 18:04 +0000, Claus Reinke wrote: > >> ghc --make -package OpenGL -package GLUT something.hs > >> I get nothing but undefined references in the linking phase. > >> C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.11.20081202/libHSGLUT-2.1.1.2.a(Window.o):fake: > >> (.text+0x15): undefined reference to `glutWarpPointer' > > > > Does ghc-pkg describe OpenGL tell you that the package needs some gl C > > lib? Eg "ld-options: -lGLU -lGL -lm" > > Yes: Then I've no idea. Is it missing all symbols or is it just a few? Does your GL dll actually contain those symbols. This doesn't immediately appear to me to be a Cabal/cabal-install problem. Perhaps we can ask for some wider help with this one. > >> Btw, is the format for the cabal config file documented somewhere? > >> I though I had set documentation to True. > > > > At the moment only in the config file itself. It lists all the fields > > (commented out) and where there are default values it lists those too. > > ah, I wasn't sure whether those '--' were meant to indicate options or > commenting (a comment in the first line might make usage unambiguous?-) Good idea. Duncan From vigalchin at gmail.com Tue Dec 2 18:43:52 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 2 18:37:15 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 Message-ID: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> Hello, Some mention is made in corresponding web pages about implementation difference of these three different DataString impl. Any advice? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/4826adc2/attachment.htm From duncan.coutts at worc.ox.ac.uk Tue Dec 2 18:59:05 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 2 18:52:31 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> Message-ID: <1228262345.10115.220.camel@localhost> On Tue, 2008-12-02 at 17:43 -0600, Galchin, Vasili wrote: > Hello, > > Some mention is made in corresponding web pages about > implementation difference of these three different DataString impl. > Any advice? Perhaps you need to ask a more specific question. Data.ByteString is a simple strict sequence of bytes (as Word8). That means the whole thing is in memory at once in one big block. Data.ByteString.Char8 provides the same type as Data.ByteString but the operations are in terms of 8-bit Chars. This is for use in files and protocols that contain ASCII as a subset. This is particularly useful for protocols containing mixed text and binary content. It should not be used instead of proper Unicode. Data.ByteString.Lazy is a different representation. As the name suggests, it's lazy like a lazy list. So like a list the whole thing does not need to be in memory if it can be processed incrementally. It supports lazy IO, like getContents does for String. It is particularly useful for handling long or unbounded streams of data in a pure style. Data.ByteString.Lazy.Char8 is the Char8 equivalent. Duncan From alexander.dunlap at gmail.com Tue Dec 2 18:59:24 2008 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Tue Dec 2 18:52:49 2008 Subject: [Haskell-cafe] Moving the messages for compiler to another file? In-Reply-To: <531137340812020256v49280d4eh19e0271123c70a16@mail.gmail.com> References: <531137340812020256v49280d4eh19e0271123c70a16@mail.gmail.com> Message-ID: <57526e770812021559s38e34131n4bc2e8cce3cdbefe@mail.gmail.com> On Tue, Dec 2, 2008 at 2:56 AM, nml wrote: > How about moving the messages for compiler to an additional file? > > My motivation is that we often face a trade-off between > aesthetical(elegant code) and practical(efficient code). > Like pragmas and strictness annotations, I often feel they make the > source code ugly. > They don't affect the semantics of our programs, do they? > > Some people would say this beautifying should be accomplished by an > editor, like hiding/showing option for those information. > > But such separation has additional benefits. > For instance, making the source code more compiler-independent. > (yeah, this is not the case with language-extensions) > And we avoid dispersing those information among our lines. (or even files) > In some cases, it would be convenient. > > I'm not sure if this idea is reasonable, reachable or just naive. > Suggestions? > > Best regards > -nml > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > One problem is that in many cases, the things that you're talking about DO affect semantics. Consider strictness annotations: > f (!x) = Just x > g x = Just x > h (Just _) = True > h Nothing = False Now h (f _|_) == _|_, but h (g _|_) == True, even though a strictness annotation was the only difference between them. (For those not already familiar with it, _|_ ("bottom") is a semantically undefined value, equivalent to an infinite loop.) I agree that it's good to reduce semantically-irrelevant code, but I'm not sure how feasible the proposal would be. I think GHC's rewrite rules may be of interest in this problem (the debate between elegant and fast code). Don Stewart has also written about this issue and has a couple of really good posts on his blog (http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast). Warm regards, Alex From ajb at spamcop.net Tue Dec 2 19:10:30 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Tue Dec 2 19:03:55 2008 Subject: [Haskell-cafe] The Knight's Tour: solutions please In-Reply-To: <20081202082927.GA4306@zombie.inf.tu-dresden.de> References: <20081130213102.GB3881@scytale.galois.com> <20081201183913.GA13054@zombie.inf.tu-dresden.de> <200812011801.09705.dan.doel@gmail.com> <20081202082927.GA4306@zombie.inf.tu-dresden.de> Message-ID: <20081202191030.g78sallakg4wcsws-nwo@webmail.spamcop.net> G'day all. Quoting Bertram Felgenhauer : > successors n b = sortWith (length . succs) . succs [...] > successors n b = sortWith (length . (succs =<<) . succs) . succs [...] > successors n b = sortWith (length . (succs =<<) . (succs =<<) . > succs) . succs [...] > These improved heuristics don't come cheap though. The heuristic is cheaper and more useful when the ply of the tree is low. It's more expensive and less useful when the ply is high. Moreover, deeper neighbour searches may only be useful in cases where the shallower searchers fail to settle on the best course of action. So something like the following might be better. Note that "d" here is an example only; I don't promise it's good. successors n b = sortWith heuristic . succs where heuristic p = let ps = succs p d = 5 - length ps `div` 2 in map length . take d . iterate (succs =<<) $ ps One more thing: Deeper neighbour searches are also unnecessarily expensive because they recompute "succs" a lot. It seems to me that if you memoed this, what you'd actually have is an explicit lazy search tree data structure. Hint hint. Cheers, Andrew Bromage From gwern0 at gmail.com Tue Dec 2 19:59:08 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Dec 2 19:52:33 2008 Subject: [Haskell-cafe] Re: Compatible problem with GHC 6.10.1 In-Reply-To: <87iqq3c98x.fsf@debian.domain> References: <878wqzxe7z.fsf@debian.domain> <87iqq3c98x.fsf@debian.domain> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Tue, Dec 2, 2008 at 2:43 AM, Andy Stewart wrote: > Thank you very much. > So anyone install XMonad with GHC 6.10.1 success? > > -- Andy Darcs XMonad and XMC support 6.10, but there is an open bug where apparently on 6.10 and x86_64 architecture, XMonad.Prompt (and derived modules) will not work correctly. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkk12dwACgkQvpDo5Pfl1oLFoACfVvz9WZ5NFTN1h+gEXJuoyNFG GjsAoJQdqz5Z5qb2r7XQp7TlMUuc+rHc =iqHY -----END PGP SIGNATURE----- From allbery at ece.cmu.edu Tue Dec 2 20:20:33 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Dec 2 20:14:01 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <49359010.8040306@btinternet.com> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> <20081201225102.GA6243@hustlerturf.com> <49359010.8040306@btinternet.com> Message-ID: <07632D23-064E-40E7-AED5-C6B671EF7EDD@ece.cmu.edu> On 2008 Dec 2, at 14:44, Andrew Coppin wrote: > Regardless, it has been my general experience that almost everything > obtained from Hackage fails miserably to compile under Windows. > (IIRC, one package even used a Bash script as part of the build > process!) I haven't seen similar problems on Linux. (But I don't use > Linux very often.) About the worst problem there was Gtk2hs being > confused about some Autoconfig stuff or something... Many packages assume you have the msys / mingw stuff installed on Windows (if they work at all; those of us who don't develop on Windows wouldn't really know how to go about being compatible). -- 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 vigalchin at gmail.com Tue Dec 2 21:18:40 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 2 21:12:03 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <1228262345.10115.220.camel@localhost> References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> Message-ID: <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> I am getting a collision with "Internal" .... sigh. vasili On Tue, Dec 2, 2008 at 5:59 PM, Duncan Coutts wrote: > On Tue, 2008-12-02 at 17:43 -0600, Galchin, Vasili wrote: > > Hello, > > > > Some mention is made in corresponding web pages about > > implementation difference of these three different DataString impl. > > Any advice? > > Perhaps you need to ask a more specific question. > > Data.ByteString is a simple strict sequence of bytes (as Word8). That > means the whole thing is in memory at once in one big block. > > Data.ByteString.Char8 provides the same type as Data.ByteString but the > operations are in terms of 8-bit Chars. This is for use in files and > protocols that contain ASCII as a subset. This is particularly useful > for protocols containing mixed text and binary content. It should not be > used instead of proper Unicode. > > > Data.ByteString.Lazy is a different representation. As the name > suggests, it's lazy like a lazy list. So like a list the whole thing > does not need to be in memory if it can be processed incrementally. It > supports lazy IO, like getContents does for String. It is particularly > useful for handling long or unbounded streams of data in a pure style. > > Data.ByteString.Lazy.Char8 is the Char8 equivalent. > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/7c19028a/attachment.htm From vigalchin at gmail.com Tue Dec 2 22:05:13 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 2 21:58:36 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> Message-ID: <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> I think I am getting a namespace collition between Data.ByteString.Lazy.Char8.ByteString and Data.ByteString.Lazy.Internal.ByteString .... here is the error message .... Couldn't match expected type `B.ByteString' against inferred type `bytestring-0.9.0.1:Data.ByteString.Lazy.Internal.ByteString' On Tue, Dec 2, 2008 at 8:18 PM, Galchin, Vasili wrote: > I am getting a collision with "Internal" .... sigh. > > > vasili > > > On Tue, Dec 2, 2008 at 5:59 PM, Duncan Coutts > wrote: > >> On Tue, 2008-12-02 at 17:43 -0600, Galchin, Vasili wrote: >> > Hello, >> > >> > Some mention is made in corresponding web pages about >> > implementation difference of these three different DataString impl. >> > Any advice? >> >> Perhaps you need to ask a more specific question. >> >> Data.ByteString is a simple strict sequence of bytes (as Word8). That >> means the whole thing is in memory at once in one big block. >> >> Data.ByteString.Char8 provides the same type as Data.ByteString but the >> operations are in terms of 8-bit Chars. This is for use in files and >> protocols that contain ASCII as a subset. This is particularly useful >> for protocols containing mixed text and binary content. It should not be >> used instead of proper Unicode. >> >> >> Data.ByteString.Lazy is a different representation. As the name >> suggests, it's lazy like a lazy list. So like a list the whole thing >> does not need to be in memory if it can be processed incrementally. It >> supports lazy IO, like getContents does for String. It is particularly >> useful for handling long or unbounded streams of data in a pure style. >> >> Data.ByteString.Lazy.Char8 is the Char8 equivalent. >> >> Duncan >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/7c5c2a7c/attachment.htm From wren at freegeek.org Tue Dec 2 22:28:50 2008 From: wren at freegeek.org (wren ng thornton) Date: Tue Dec 2 22:22:16 2008 Subject: [Haskell-cafe] Deriving In-Reply-To: References: Message-ID: <4935FCF2.5050701@freegeek.org> Daryoush Mehrtash wrote: > What happens when a type adds driving such as: > > newtype SupplyT s m a = SupplyT (StateT [s] m a) > deriving (Functor, Monad, MonadTrans, MonadIO) > > > Two questions: > > How does the deriving implement the instance? With GeneralizedNewtypeDeriving, since newtypes are just a reinterpretation of the underlying type, the deriving clause just uses the instance for the underlying type (massaging it with the wrapping/unwrapping functions for the newtype). The primary use for this is for defining a newtype on monad transformer stacks, for which it succeeds excellently. However, if the semantics of your newtype are different than the underlying type w.r.t. the type class, then it's not so good. For the more basic kind of deriving clause, the compiler knows about how to create generic instances for obvious things, e.g. the compiler can derive the obvious Show instance by doing introspection on the source code. However, these derivations are limited to classes with an obvious implementation based solely on the structure of the type definition. -- Live well, ~wren From vigalchin at gmail.com Tue Dec 2 23:56:06 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 2 23:49:28 2008 Subject: [Haskell-cafe] ByteString web site papers Message-ID: <5ae4f2ba0812022056s633a0397yc7ed08b1f3f09029@mail.gmail.com> Hello, http://www.cse.unsw.edu.au/~dons/fps.html Are the papers/slides still up-to-date for someone to get up-to-speed on ByteString motivation and implementation? Anything more recent? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081202/398edc66/attachment.htm From lazycat.manatee at gmail.com Wed Dec 3 00:18:50 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Wed Dec 3 00:13:34 2008 Subject: [Haskell-cafe] Install Yi editor with GHC 6.10.1 Message-ID: <873ah5alad.fsf@debian.domain> Hi all, I have install GHC 6.10.1 and Gtk2hs (darcs version) in Debian. So i want to ask, have anyone install Yi (darcs version) with GHC 6.10.1 successfully? And the best way to install darcs version Yi? Thank you very much! -- Andy From johanj at cs.uu.nl Wed Dec 3 01:11:18 2008 From: johanj at cs.uu.nl (Johan Jeuring) Date: Wed Dec 3 01:05:04 2008 Subject: [Haskell-cafe] Deriving In-Reply-To: References: Message-ID: > What happens when a type adds driving such as: > > newtype SupplyT s m a = SupplyT (StateT [s] m a) > > deriving (Functor, Monad, MonadTrans, MonadIO) > > Two questions: > > How does the deriving implement the instance? > > Is there a way for me to add my own classes in the deriving? for > example > > newtype ..... > deriving( xyz) In general you would have to resort to generic programming techniques to obtain your own deriving mechanism. See the generics category on Hackage for libraries: http://hackage.haskell.org/packages/archive/pkg-list.html To find out what you can do with the various generic programming techniques, you can read (shameless plugs): Alexey Rodriguez Yakushev, Johan Jeuring, Patrik Jansson, Alex Gerdes, Oleg Kiselyov, Bruno C. d. S. Oliviera. Comparing Libraries for Generic Programming in Haskell. In Andy Gill, editor, Proceedings of the ACM SIGPLAN Haskell Symposium. An extended version is available as Technical report Utrecht University UU-CS-2008-010, 2008. Ralf Hinze, Johan Jeuring, and Andres L?h. Comparing approaches to generic programming in Haskell. In Roland Backhouse, Jeremy Gibbons, Ralf Hinze, and Johan Jeuring, editors, Lecture notes of the Spring School on Datatype-Generic Programming 2006, LNCS 4719, pages 72 - 149, 2007, Springer-Verlag. -- Johan Jeuring From jason.dusek at gmail.com Wed Dec 3 02:00:09 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Dec 3 01:53:31 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <49359010.8040306@btinternet.com> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> <20081201225102.GA6243@hustlerturf.com> <49359010.8040306@btinternet.com> Message-ID: <42784f260812022300j1386a482t531087701fc1304a@mail.gmail.com> Andrew Coppin wrote: > ...it has been my general experience that almost everything > obtained from Hackage fails miserably to compile under > Windows. (IIRC, one package even used a Bash script as part of > the build process!) I haven't seen similar problems on Linux. > (But I don't use Linux very often.) I try very hard to make my programs work on Windows; and indeed, one of things I appreciate about Haskell is how easy it is to create binaries and packages that are cross platform. However, the only time I actually use Windows is to build and test my Haskell packages. Most of the people on this list -- and I wager, most people on the mailing lists for any open source programming language -- are working on a NIXalike; we can work with bug reports, but we can't very well be the fabled "many eyeballs" on a platform we don't use. Ask not what your Haskell can do for you, but rather what you can do for your Haskell :) > About the worst problem there was Gtk2hs being confused about > some Autoconfig stuff or something... Well, what else would a package built with GNU toolchain be confused about? Is there some miraculous language and package system for it where compiling libraries made with autotools is just a snap on Windows? -- _jsn From ketil at malde.org Wed Dec 3 02:32:13 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Dec 3 02:25:36 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> (Vasili Galchin's message of "Tue\, 2 Dec 2008 21\:05\:13 -0600") References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> Message-ID: <87skp5zpc2.fsf@malde.org> "Galchin, Vasili" writes: > I think I am getting a namespace collition between > > Data.ByteString.Lazy.Char8.ByteString > > and > > Data.ByteString.Lazy.Internal.ByteString .... You rarely need to import 'Internal' directly. > here is the error message .... > > Couldn't match expected type `B.ByteString' > against inferred type > `bytestring-0.9.0.1:Data.ByteString.Lazy.Internal.ByteString' Are you sure this is not just a versioning problem? I.e. that some library is built against bytestring-0.X.Y, but your current import is bytestring-0.A.B, but your program expects these to be the same? (And they probably are, but the compiler can't really tell). -k -- If I haven't seen further, it is by standing in the footprints of giants From mad.one at gmail.com Wed Dec 3 02:46:11 2008 From: mad.one at gmail.com (Austin Seipp) Date: Wed Dec 3 02:39:36 2008 Subject: [Haskell-cafe] Install Yi editor with GHC 6.10.1 In-Reply-To: <873ah5alad.fsf@debian.domain> References: <873ah5alad.fsf@debian.domain> Message-ID: <1228290252-sup-6668@existential.local> Excerpts from lazycat.manatee's message of Tue Dec 02 23:18:50 -0600 2008: > Hi all, > > I have install GHC 6.10.1 and Gtk2hs (darcs version) in Debian. > So i want to ask, have anyone install Yi (darcs version) with GHC 6.10.1 > successfully? Yes. cabal install is basically the easiest way to do it: $ cabal update $ cabal install yi > And the best way to install darcs version Yi? $ darcs get http://code.haskell.org/yi yi-darcs $ cd yi-darcs $ cabal install You will need darcs v2 (I normally use the yi darcs repo fwiw, jpb pushes lots of little fixes/optimizations regularly. Recently in yi 0.5.2 and the darcs version some major memory leaks have been fixed it seems.) Austin From vigalchin at gmail.com Wed Dec 3 02:46:29 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Dec 3 02:39:54 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <87skp5zpc2.fsf@malde.org> References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> <87skp5zpc2.fsf@malde.org> Message-ID: <5ae4f2ba0812022346s289403d4ldbf03e96ae9bd401@mail.gmail.com> On Wed, Dec 3, 2008 at 1:32 AM, Ketil Malde wrote: > "Galchin, Vasili" writes: > > > I think I am getting a namespace collition between > > > > Data.ByteString.Lazy.Char8.ByteString > > > > and > > > > Data.ByteString.Lazy.Internal.ByteString .... > > You rarely need to import 'Internal' directly. > > > here is the error message .... > > > > Couldn't match expected type `B.ByteString' > > against inferred type > > `bytestring-0.9.0.1:Data.ByteString.Lazy.Internal.ByteString' > > Are you sure this is not just a versioning problem? I.e. that some > library is built against bytestring-0.X.Y, but your current import is > bytestring-0.A.B, but your program expects these to be the same? (And > they probably are, but the compiler can't really tell). ^^ oh great ;^) how can ascertain this situation? - vasili > > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081203/5e99bd5a/attachment.htm From vigalchin at gmail.com Wed Dec 3 02:52:01 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Dec 3 02:45:25 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <87skp5zpc2.fsf@malde.org> References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> <87skp5zpc2.fsf@malde.org> Message-ID: <5ae4f2ba0812022352x78ca7a60mde567d32316c6c4e@mail.gmail.com> Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. package binary-0.4.2 requires bytestring-0.9.0.1 package bio-0.3.4.1 requires bytestring-0.9.1.0 ah ha .. Ketil, this is what you are saying? If so, how do I fix? install a newer version of binary? regards, vasili On Wed, Dec 3, 2008 at 1:32 AM, Ketil Malde wrote: > "Galchin, Vasili" writes: > > > I think I am getting a namespace collition between > > > > Data.ByteString.Lazy.Char8.ByteString > > > > and > > > > Data.ByteString.Lazy.Internal.ByteString .... > > You rarely need to import 'Internal' directly. > > > here is the error message .... > > > > Couldn't match expected type `B.ByteString' > > against inferred type > > `bytestring-0.9.0.1:Data.ByteString.Lazy.Internal.ByteString' > > Are you sure this is not just a versioning problem? I.e. that some > library is built against bytestring-0.X.Y, but your current import is > bytestring-0.A.B, but your program expects these to be the same? (And > they probably are, but the compiler can't really tell). > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081203/95c00fa3/attachment.htm From lazycat.manatee at gmail.com Wed Dec 3 02:54:52 2008 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Wed Dec 3 02:48:39 2008 Subject: [Haskell-cafe] Re: Install Yi editor with GHC 6.10.1 References: <873ah5alad.fsf@debian.domain> <1228290252-sup-6668@existential.local> Message-ID: <87k5ah4rsj.fsf@debian.domain> Hi Austin, Austin Seipp writes: > Excerpts from lazycat.manatee's message of Tue Dec 02 23:18:50 -0600 2008: >> Hi all, >> >> I have install GHC 6.10.1 and Gtk2hs (darcs version) in Debian. >> So i want to ask, have anyone install Yi (darcs version) with GHC 6.10.1 >> successfully? > > Yes. cabal install is basically the easiest way to do it: > > $ cabal update > $ cabal install yi > >> And the best way to install darcs version Yi? > > $ darcs get http://code.haskell.org/yi yi-darcs > $ cd yi-darcs > $ cabal install > > You will need darcs v2 (I normally use the yi darcs repo fwiw, jpb > pushes lots of little fixes/optimizations regularly. Recently in yi > 0.5.2 and the darcs version some major memory leaks have been fixed it > seems.) > > Austin Thank you. But i have install Yi 0.5.2 and 0.5.3 and got same error: ,---- | .... | | [ 78 of 105] Compiling Yi.Core ( Yi/Core.hs, dist/build/Yi/Core.o ) | [ 79 of 105] Compiling Yi.File ( Yi/File.hs, dist/build/Yi/File.o ) | [ 80 of 105] Compiling Yi.MiniBuffer ( Yi/MiniBuffer.hs, dist/build/Yi/MiniBuffer.o ) | [ 81 of 105] Compiling Yi.Dired ( Yi/Dired.hs, dist/build/Yi/Dired.o ) | [ 82 of 105] Compiling Yi.Eval ( Yi/Eval.hs, dist/build/Yi/Eval.o ) | [ 83 of 105] Compiling Yi.Mode.Compilation ( Yi/Mode/Compilation.hs, dist/build/Yi/Mode/Compilation.o ) | [ 84 of 105] Compiling Yi.Mode.Interactive ( Yi/Mode/Interactive.hs, dist/build/Yi/Mode/Interactive.o ) | [ 85 of 105] Compiling Yi.Mode.Haskell ( Yi/Mode/Haskell.hs, dist/build/Yi/Mode/Haskell.o ) | [ 86 of 105] Compiling Yi.Search ( Yi/Search.hs, dist/build/Yi/Search.o ) | [ 87 of 105] Compiling Yi.TextCompletion ( Yi/TextCompletion.hs, dist/build/Yi/TextCompletion.o ) | [ 88 of 105] Compiling Yi.UI.Gtk.ProjectTree ( Yi/UI/Gtk/ProjectTree.hs, dist/build/Yi/UI/Gtk/ProjectTree.o ) | | Yi/UI/Gtk/ProjectTree.hs:19:40: | Module `Graphics.UI.Gtk' does not export `Event' | cabal: Error: some packages failed to install: | yi-0.5.2 failed during the building phase. The exception was: | exit: ExitFailure 1 `---- Any help? -- Andy From martin.hofmann at uni-bamberg.de Wed Dec 3 02:59:53 2008 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Wed Dec 3 02:50:39 2008 Subject: [Haskell-cafe] What causes <>? Message-ID: <1228291193.6022.1.camel@ios.cogsys.wiai.uni-bamberg.de> I've already posted this mail on haskell-cafe, but apparently the subject suggested a too simple question, so I try it here again. I am picking up a discussion with the same topic from haskell-users on 8th November. Thunks with reference on themselves was mentioned as main reason for <>. > A safe recursive definition would be > let x = Foo (x+1) > However, if you leave out the constructor, > let x = x + 1 > you get a <> (or a deadlock). > Are there any other reasons? I am trying to debug monadic code which stores state information in a record maintaining several Data.Maps, but in vain so far. A state is modified/changed in several steps by a compound function i.e. changeA $ changeB $ changeC state Could this also lead to a deadlock? If so, can I prevent this using CPS? If the state transformation is the main purpose/computation of the monad at all, is it better to use CPS? Is code using mtl, records or Data.Map more prone to <> or does this not matter at all. How can I identify self-referencing thunks more easily? Is there any rule of thumb to prevent <>? Are there any less obvious newbie mistakes causing < then the one above? Sorry, a lot of questions at once, but I am kind of helpless because I can't find any reason of my <>, so any comments, experience, and tips are highly appreciated. Thanks, Martin From vigalchin at gmail.com Wed Dec 3 03:01:15 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Dec 3 02:54:37 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <5ae4f2ba0812022352x78ca7a60mde567d32316c6c4e@mail.gmail.com> References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> <87skp5zpc2.fsf@malde.org> <5ae4f2ba0812022352x78ca7a60mde567d32316c6c4e@mail.gmail.com> Message-ID: <5ae4f2ba0812030001r4b38a0b3x3d2d247bf4890e5e@mail.gmail.com> based on "ghc-pkg list" .... in my "global" ghc install I have bytestring-0.9.0.1 in my "local" ghc install I have bytestring-0.9.1.0 this difference of versions I strongly think is causing my problems.. When I run "cabal install bytestring" from the CLI, I get "resolving differences" .... If my assertion that the "delta" between the "global" vs "local" is causing my compile problems, then what should I do?? Regards, Vasili On Wed, Dec 3, 2008 at 1:52 AM, Galchin, Vasili wrote: > Warning: This package indirectly depends on multiple versions of the same > package. This is highly likely to cause a compile failure. > package binary-0.4.2 requires bytestring-0.9.0.1 > package bio-0.3.4.1 requires bytestring-0.9.1.0 > > > ah ha .. Ketil, this is what you are saying? If so, how do I fix? install a > newer version of binary? > > regards, vasili > > On Wed, Dec 3, 2008 at 1:32 AM, Ketil Malde wrote: > >> "Galchin, Vasili" writes: >> >> > I think I am getting a namespace collition between >> > >> > Data.ByteString.Lazy.Char8.ByteString >> > >> > and >> > >> > Data.ByteString.Lazy.Internal.ByteString .... >> >> You rarely need to import 'Internal' directly. >> >> > here is the error message .... >> > >> > Couldn't match expected type `B.ByteString' >> > against inferred type >> > `bytestring-0.9.0.1:Data.ByteString.Lazy.Internal.ByteString' >> >> Are you sure this is not just a versioning problem? I.e. that some >> library is built against bytestring-0.X.Y, but your current import is >> bytestring-0.A.B, but your program expects these to be the same? (And >> they probably are, but the compiler can't really tell). >> >> -k >> -- >> If I haven't seen further, it is by standing in the footprints of giants >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081203/c2464f74/attachment.htm From ketil at malde.org Wed Dec 3 03:10:18 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Dec 3 03:03:41 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <5ae4f2ba0812022352x78ca7a60mde567d32316c6c4e@mail.gmail.com> (Vasili Galchin's message of "Wed\, 3 Dec 2008 01\:52\:01 -0600") References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> <87skp5zpc2.fsf@malde.org> <5ae4f2ba0812022352x78ca7a60mde567d32316c6c4e@mail.gmail.com> Message-ID: <87hc5lznkl.fsf@malde.org> "Galchin, Vasili" writes: > Warning: This package indirectly depends on multiple versions of the same > package. This is highly likely to cause a compile failure. > package binary-0.4.2 requires bytestring-0.9.0.1 > package bio-0.3.4.1 requires bytestring-0.9.1.0 > ah ha .. Ketil, this is what you are saying? Yes, exactly. > If so, how do I fix? install a newer version of binary? Just recompiling it against bytestring-0.9.1.0 would suffice. You really should anyway, bytestring-0.9.0.1 has a nasty performance issue. -k -- If I haven't seen further, it is by standing in the footprints of giants From ashley at semantic.org Wed Dec 3 04:15:35 2008 From: ashley at semantic.org (Ashley Yakeley) Date: Wed Dec 3 04:09:01 2008 Subject: [Haskell-cafe] Re: Fun with type functions In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C33281447D7F@EA-EXMSG-C334.europe.corp.microsoft.com> References: <638ABD0A29C8884A91BC5FB5C349B1C33281447D7F@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <49364E37.6030807@semantic.org> Simon Peyton-Jones wrote: > can you tell us about the most persuasive, fun application > you've encountered, for type families or functional dependencies? I'm using them to provide witnesses to lenses. Given two lenses on the same base type, I want to compare them, and if they're the same lens, know that they have the same view type. data Lens base view = MkLens { -- lensWitness :: ???, lensGet :: base -> view, lensPut :: base -> view -> base }; How do I compare "Lens base view1" and "Lens base view2", and match up view1 and view2? The difficulty is that my witnesses are monomorphic, while a lens may be polymorphic. For instance, the lens corresponding to the "fst" function: fstLens :: Lens (a,b) a; fstLens = MkLens { lensGet = fst, lensPut = \(_,b) a -> (a,b) }; I only want to generate one open witness for fstLens, but what is its type? This is where type functions come in. I have a type family TF, and a basic set of instances: type family TF tf x; data TFIdentity; type instance TF TFIdentity x = x; data TFConst a; type instance TF (TFConst a) x = a; data TFApply (f :: * -> *); type instance TF (TFApply f) x = f x; data TFMatch; type instance TF TFMatch (f a) = a; data TFMatch1; type instance TF TFMatch1 (f a b) = a; data TFCompose tf1 tf2; type instance TF (TFCompose tf1 tf2) x = TF tf1 (TF tf2 x); I create a new witness type, that witnesses type functions: import Data.Witness; data TFWitness w x y where { MkTFWitness :: w tf -> TFWitness w x (TF tf x); }; instance (SimpleWitness w) => SimpleWitness (TFWitness w x) where { matchWitness (MkTFWitness wtf1) (MkTFWitness wtf2) = do { MkEqualType <- matchWitness wtf1 wtf2; return MkEqualType; }; }; So for my lens type, I want a witness for the type function from base to view: data Lens base view = MkLens { lensWitness :: TFWitness IOWitness base view, lensGet :: base -> view, lensPut :: base -> view -> base }; For our "fst" lens, I can now generate a witness for the function from "(a,b)" to "a". fstWitness :: IOWitness TFMatch1; fstWitness <- newIOWitness; -- language extension fstLens :: Lens (a,b) a; fstLens = MkLens { lensWitness = MkTFWitness fstWitness, lensGet = fst, lensPut = \(_,b) a -> (a,b) }; I can now compare two lenses like this: get1put2 :: Lens base view1 -> Lens base view2 -> base -> Maybe base; get1put2 lens1 lens2 b = do { MkEqualType <- matchWitness (lensWitness lens1) (lensWitness lens2); return (lensPut lens2 b (lensGet lens1 b)); }; (Actually, I'm doing something a bit more useful than get1put2.) -- Ashley Yakeley From voigt at tcs.inf.tu-dresden.de Wed Dec 3 04:30:17 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Dec 3 04:23:41 2008 Subject: [Haskell-cafe] What causes <>? In-Reply-To: <1228291193.6022.1.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1228291193.6022.1.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <493651A9.1050204@tcs.inf.tu-dresden.de> Martin Hofmann wrote: > I've already posted this mail on haskell-cafe, but apparently the > subject suggested a too simple question, so I try it here again. I am > picking up a discussion with the same topic from haskell-users on > 8th November. Note that you have been sending to haskell-cafe again. Your recipient name says haskell-beginners, but the address is haskell-cafe. Anyway, <> really means a loop in evalutation order, not some statebased deadlock (see below). > Thunks with reference on themselves was mentioned as main reason for > <>. > > >>A safe recursive definition would be >> let x = Foo (x+1) >>However, if you leave out the constructor, >> let x = x + 1 >>you get a <> (or a deadlock). >> > > > Are there any other reasons? > > I am trying to debug monadic code which stores state information in a > record maintaining several Data.Maps, but in vain so far. A state is > modified/changed in several steps by a compound function i.e. > > changeA $ changeB $ changeC state > > Could this also lead to a deadlock? I don't think so. At least not in a way that leads to <>. If you get <> then you really have some infinite recursion in your program. Maybe you can track it down with Debug.Trace.trace. If so, can I prevent this using CPS? -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From voigt at tcs.inf.tu-dresden.de Wed Dec 3 04:32:08 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Dec 3 04:25:30 2008 Subject: [Haskell-cafe] What causes <>? In-Reply-To: <493651A9.1050204@tcs.inf.tu-dresden.de> References: <1228291193.6022.1.camel@ios.cogsys.wiai.uni-bamberg.de> <493651A9.1050204@tcs.inf.tu-dresden.de> Message-ID: <49365218.30300@tcs.inf.tu-dresden.de> Janis Voigtlaender wrote: > Martin Hofmann wrote: > >> I've already posted this mail on haskell-cafe, but apparently the >> subject suggested a too simple question, so I try it here again. I am >> picking up a discussion with the same topic from haskell-users on >> 8th November. > > > Note that you have been sending to haskell-cafe again. Your recipient > name says haskell-beginners, but the address is haskell-cafe. > > Anyway, <> really means a loop in evalutation order, not some > statebased deadlock (see below). > >> Thunks with reference on themselves was mentioned as main reason for >> <>. >> >> >>> A safe recursive definition would be >>> let x = Foo (x+1) >>> However, if you leave out the constructor, >>> let x = x + 1 >>> you get a <> (or a deadlock). >>> >> >> >> Are there any other reasons? >> I am trying to debug monadic code which stores state information in a >> record maintaining several Data.Maps, but in vain so far. A state is >> modified/changed in several steps by a compound function i.e. >> >> changeA $ changeB $ changeC state >> >> Could this also lead to a deadlock? > > > I don't think so. At least not in a way that leads to <>. If you > get <> then you really have some infinite recursion in your > program. Maybe you can track it down with Debug.Trace.trace. > If so, can I prevent this using CPS? Oh, that last question was from the original mail, not from my answer. In any case, I don't think that CPS will help in finding the looping error in your program. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From hpacheco at gmail.com Wed Dec 3 04:36:31 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Wed Dec 3 04:29:54 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> References: <20081108203244.GA6568@berkeley.edu> <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> Message-ID: <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> Good morning, I wonder if it is possible to embed regular HTML code inside gitit (on 0.3.2) pages, such as java applets like the following. I am assuming that as a wiki, it is only possible to point to external pages. Thanks, hugo On Sun, Nov 9, 2008 at 10:01 PM, Chris Eidhof wrote: > If anyone else has problems installing gitit, try updating your > cabal-install (and cabal). I had "old" versions on my computer, and updating > them solved my gitit build-problems. > > -chris > > > On 9 nov 2008, at 22:41, John MacFarlane wrote: > > I've just uploaded a new version (0.2.1) that requires HAppS >= 0.9.3 && >> < 0.9.4. (There are small API changes from 0.9.2 to 0.9.3, so I thought >> it best not to allow 0.9.2.x, even though it still compiles with a >> warning.) >> >> +++ Hugo Pacheco [Nov 09 08 20:41 ]: >> >>> a new HAppS version [1]0.9.3.1 has been released, and gitit requires >>> HApps==[2]0.9.2.1. should ti be ok just to relax the dependency? >>> >>> On Sat, Nov 8, 2008 at 8:32 PM, John MacFarlane <[3]jgm@berkeley.edu> >>> wrote: >>> >>> I've uploaded an early version of gitit, a Haskell wiki program, to >>> HackageDB. Gitit uses HAppS as a webserver, git for file storage, >>> pandoc for rendering the (markdown) pages, and highlighting-kate for >>> highlighted source code. >>> >>> Some nice features of gitit: >>> >>> - Pages and uploaded files are stored in a git repository and may >>> be added, deleted, and modified directly using git. >>> - Pages may be organized into subdirectories. >>> - Pandoc's extended version of markdown is used, so you can do >>> tables, >>> footnotes, syntax-highlighted code blocks, and LaTeX math. (And >>> you can you pandoc to convert pages into many other formats.) >>> - Math is rendered using jsMath (which must be installed >>> separately). >>> - Source code files in the repository are automatically rendered with >>> syntax highlighting (plain/text version is also available). >>> >>> You can check it out on my webserver: [4] >>> http://johnmacfarlane.net:5001/ >>> Or try it locally: >>> >>> cabal update >>> cabal install pandoc -fhighlighting >>> cabal install gitit >>> gitit # note: this will create two subdirectories in the working >>> directory >>> # then browse to [5]http://localhost:5001. >>> >>> There's a git repository at [6] >>> http://github.com/jgm/gitit/tree/master. >>> Comments and patches are welcome. >>> >>> John >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> [7]Haskell-Cafe@haskell.org >>> [8]http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> -- >>> [9]www.di.uminho.pt/~hpacheco >>> >>> References >>> >>> Visible links >>> 1. http://0.9.3.1/ >>> 2. http://0.9.2.1/ >>> 3. mailto:jgm@berkeley.edu >>> 4. http://johnmacfarlane.net:5001/ >>> 5. http://localhost:5001/ >>> 6. http://github.com/jgm/gitit/tree/master >>> 7. mailto:Haskell-Cafe@haskell.org >>> 8. http://www.haskell.org/mailman/listinfo/haskell-cafe >>> 9. http://www.di.uminho.pt/~hpacheco >>> >> >> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081203/894c7f33/attachment.htm From magnus at therning.org Wed Dec 3 04:36:39 2008 From: magnus at therning.org (Magnus Therning) Date: Wed Dec 3 04:30:03 2008 Subject: [Haskell-cafe] Cabal and Hat? Message-ID: Is it possible to use cabal to build the files that hat would need to do tracing (i.e. .htx files)? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From apfelmus at quantentunnel.de Wed Dec 3 05:04:36 2008 From: apfelmus at quantentunnel.de (Apfelmus, Heinrich) Date: Wed Dec 3 04:58:04 2008 Subject: [Haskell-cafe] Re: What causes <>? In-Reply-To: <1228291193.6022.1.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1228291193.6022.1.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: Martin Hofmann wrote: > Thunks with reference on themselves was mentioned as main reason for > <>. > >> A safe recursive definition would be >> let x = Foo (x+1) >> However, if you leave out the constructor, >> let x = x + 1 >> you get a <> (or a deadlock). >> > > Are there any other reasons? A program that exits with <> is basically a program that runs forever. Examples of programs that run forever are let x = x + 1 in x let f x = f x in f 1 In special cases, the run-time system is able to detect that the program would run forever, and exits with <> if that happens. > Sorry, a lot of questions at once, but I am kind of helpless because I > can't find any reason of my <>, so any comments, experience, and > tips are highly appreciated. Sometimes, a simple cause is accidentally using the same variable name, i.e. writing let (c,s) = foobar s in ... while you meant let (c,s') = foobar s in ... At other times, non-termination is caused by not using enough irrefutable patterns. But this usually only happens when writing algorithms that heavily exploit recursion and laziness, which probably doesn't apply to your case. You may want to try the new GHCi debugger, maybe it helps finding the loop. Regards, H. Apfelmus From martin.hofmann at uni-bamberg.de Wed Dec 3 05:12:42 2008 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Wed Dec 3 05:03:27 2008 Subject: [Haskell-cafe] Re: What causes <>? Message-ID: <1228299162.6022.9.camel@ios.cogsys.wiai.uni-bamberg.de> I was not sure about it, so I just speculated. Anyway, thanks a lot. martin From duncan.coutts at worc.ox.ac.uk Wed Dec 3 06:22:23 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 3 06:15:47 2008 Subject: [Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8 In-Reply-To: <5ae4f2ba0812022352x78ca7a60mde567d32316c6c4e@mail.gmail.com> References: <5ae4f2ba0812021543u172a0ecct8e59f974a14ed372@mail.gmail.com> <1228262345.10115.220.camel@localhost> <5ae4f2ba0812021818v7bb10ad2u7b5ef255b5c01c4c@mail.gmail.com> <5ae4f2ba0812021905g77343ecdm5e9d5d5e4d75f894@mail.gmail.com> <87skp5zpc2.fsf@malde.org> <5ae4f2ba0812022352x78ca7a60mde567d32316c6c4e@mail.gmail.com> Message-ID: <1228303343.10115.250.camel@localhost> On Wed, 2008-12-03 at 01:52 -0600, Galchin, Vasili wrote: > Warning: This package indirectly depends on multiple versions of the > same > package. This is highly likely to cause a compile failure. > package binary-0.4.2 requires bytestring-0.9.0.1 > package bio-0.3.4.1 requires bytestring-0.9.1.0 > > > ah ha .. Ketil, this is what you are saying? If so, how do I fix? > install a newer version of binary? This is the most significant issue that cabal-install addresses. It works out what needs to be rebuilt to get consistent dependencies. In this example you could run: $ cabal install --dry-run in the directory containing your package and it will say what it would install or re-install to be able to build your package. If you drop the --dry-run then it will actually do it, including installing your package. Duncan From duncan.coutts at worc.ox.ac.uk Wed Dec 3 06:26:56 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 3 06:20:21 2008 Subject: [Haskell-cafe] ByteString web site papers In-Reply-To: <5ae4f2ba0812022056s633a0397yc7ed08b1f3f09029@mail.gmail.com> References: <5ae4f2ba0812022056s633a0397yc7ed08b1f3f09029@mail.gmail.com> Message-ID: <1228303616.10115.251.camel@localhost> On Tue, 2008-12-02 at 22:56 -0600, Galchin, Vasili wrote: > Hello, > > http://www.cse.unsw.edu.au/~dons/fps.html > > Are the papers/slides still up-to-date for someone to get up-to-speed > on ByteString motivation and implementation? Yes. > Anything more recent? It links to the stream fusion paper but that's more about lists than bytestrings. Duncan From duncan.coutts at worc.ox.ac.uk Wed Dec 3 06:28:22 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 3 06:21:45 2008 Subject: [Haskell-cafe] Cabal and Hat? In-Reply-To: References: Message-ID: <1228303702.10115.253.camel@localhost> On Wed, 2008-12-03 at 09:36 +0000, Magnus Therning wrote: > Is it possible to use cabal to build the files that hat would need to > do tracing (i.e. .htx files)? No, but if you'd like to add support that'd be a great service to everyone. Duncan From info at tobias-kraentzer.de Wed Dec 3 08:22:39 2008 From: info at tobias-kraentzer.de (=?ISO-8859-1?Q?Tobias_Kr=E4ntzer?=) Date: Wed Dec 3 08:16:22 2008 Subject: [Haskell-cafe] Problem building HXQ on Mac OS 10.5.5 In-Reply-To: References: <6E438D44-73F6-4ACD-9BB8-35BEEC3FD836@tobias-kraentzer.de> Message-ID: <351FAD3B-AE67-4CE6-A48E-BB5F581991A8@tobias-kraentzer.de> Hi, Am 03.12.2008 um 02:00 schrieb Gwern Branwen: > I haven't looked at the source, so take this as off-the-cuff: try > importing not Control.Exception but Control.OldException. changing "Control.Exception"to "Control.OldException" didn't work. But changing "SomeException" to "Exception" seems to solve the problem (see below). At least I can now built it and use xquery. I think these days I get more in to it and understand what I was doing. ;-) Could it be a problem with the version of GHC? I'm using 6.10.1. Is "SomeException" still supported? At the moment I don't know how to look these things up. Regard, . . . Tobias -- Original: #if __GLASGOW_HASKELL__ >= 609 type E = C.SomeException #else type E = C.Exception #endif -- Modified: type E = C.Exception -- Tobias Kr?ntzer | Scharnweberstra?e 52a | 10247 Berlin Telefon: +49-30-75636668 | +49-178-1353136 XMPP: anagrom_ataf@jabber.ccc.de From mailing_list at istitutocolli.org Wed Dec 3 09:09:21 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Wed Dec 3 09:02:47 2008 Subject: [Haskell-cafe] handles and foreign C functions Message-ID: <20081203140921.GD26844@Andrea.Nowhere.net> Hello, suppose a simple C function like this: void printStuff(FILE *f) { fprintf (f, "Hello World\n"); } In order to use it I need to import fopen and pass to it a Ptr CFile: foreign import ccall unsafe "fopen" fopen :: CString -> CString -> IO (Ptr CFile) foreign import ccall unsafe "fclose" fclose :: Ptr CFile -> IO CInt foreign import ccall unsafe "printStuff" printStuff :: Ptr CFile -> IO () main = withCString "tmp.txt" $ \cpath -> withCString "w" $ \cmode -> do cfile <- throwErrnoIfNull "fopen: " (fopen cpath cmode) printStuff cfile fclose cfile How can I pass to printStuff a stdout FILE pointer? If, for instance, I do: foreign import ccall unsafe "stdout" c_stdout :: Ptr CFile main = withCString "tmp.txt" $ \cpath -> withCString "w" $ \cmode -> do printStuff c_stdout I get a segmentation fault. What am I missing? TIA Andrea From lionel at gamr7.com Wed Dec 3 09:36:14 2008 From: lionel at gamr7.com (Lionel Barret De Nazaris) Date: Wed Dec 3 09:26:12 2008 Subject: [Haskell-cafe] gmp license == no commercial/closed source haskell software ?? Message-ID: <4936995E.9050605@gamr7.com> I've just discovered the GMP license problem. (see http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes) From my understanding, the gmp is GPL, GHC statically links it on windows. As a consequence, any program compiled using GHC must be distributed under a GPL compatible license. In the threads I've read, some workarounds are proposed on linux and OsX, but I didn't see anything on windows. Is the situation still the same ? Does anybody know a work-around to make a closed-source programm in haskell without violating the GPL ? ( Note this could block Haskell in our company. ) -- Best Regards, lionel Barret de Nazaris, ========================= Gamr7 : Cities for Games http://www.gamr7.com From dons at galois.com Wed Dec 3 09:36:57 2008 From: dons at galois.com (Don Stewart) Date: Wed Dec 3 09:30:14 2008 Subject: [Haskell-cafe] gmp license == no commercial/closed source haskell software ?? In-Reply-To: <4936995E.9050605@gamr7.com> References: <4936995E.9050605@gamr7.com> Message-ID: <20081203143657.GD16108@scytale.galois.com> lionel: > I've just discovered the GMP license problem. (see > http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes) > > From my understanding, the gmp is GPL, GHC statically links it on windows. > As a consequence, any program compiled using GHC must be distributed > under a GPL compatible license. GMP is *LGPL*. > In the threads I've read, some workarounds are proposed on linux and > OsX, but I didn't see anything on windows. > > Is the situation still the same ? > Does anybody know a work-around to make a closed-source programm in > haskell without violating the GPL ? It is LGPL, which is a very important distinction. It just must be possible to replace the libgmp component with another that has been modified - you can't actively prevent people replacing the libgmp component. Supporting this is trivial with a dynamically linked / DLL libgmp. With a statically linked one, it is also possible, since the API calls to libgmp are specified. This shouldn't prevent commercial use -- lots of other companies have decided this is OK. You just need to be aware of it. -- Don From jonathanccast at fastmail.fm Wed Dec 3 09:45:09 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Dec 3 09:38:32 2008 Subject: [Haskell-cafe] gmp license == no commercial/closed source haskell software ?? In-Reply-To: <4936995E.9050605@gamr7.com> References: <4936995E.9050605@gamr7.com> Message-ID: <1228315509.6209.8.camel@jonathans-macbook> On Wed, 2008-12-03 at 15:36 +0100, Lionel Barret De Nazaris wrote: > I've just discovered the GMP license problem. (see > http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes) > > From my understanding, the gmp is GPL, GHC statically links it on > windows. Lesser GPL: http://www.gnu.org/copyleft/lesser.html It doesn't actually have a section 2(c) as per the wiki. Section 4(d)0 of the LGPL is traditionally taken to allow static linking, as long as you distribute a) The source of the version of GMP you use (corresponding source), and b) Object files/libraries for your program + the GHC RTS suitable for static linking with your user's (possibly modified) builds of the distributed GMP source. jcc From jgm at berkeley.edu Wed Dec 3 10:44:35 2008 From: jgm at berkeley.edu (John MacFarlane) Date: Wed Dec 3 10:38:01 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> References: <20081108203244.GA6568@berkeley.edu> <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> Message-ID: <20081203154435.GB7436@berkeley.edu> +++ Hugo Pacheco [Dec 03 08 09:36 ]: > Good morning, > I wonder if it is possible to embed regular HTML code inside gitit (on > 0.3.2) pages, such as java applets like the following. > 400 ALT = "you should see an instance of GHood here, as an applet"> NAME = "eventSource" VALUE ="factHylo.log"> ="150"> > I am assuming that as a wiki, it is only possible to point to external > pages. > Thanks, > hugo Of course you can put any HTML you like in the page template (template.html). But I assume you are asking about HTML inside the wiki pages themselves. Although markdown allows embedded HTML, gitit uses pandoc's HTML sanitization feature, so things that might be dangerous (like applets) will be filtered out and replaced by comments. You could easily modify the code to remove the santitization feature. Just change the textToPandoc function so that stateSanitizeHtml is set to False. John From bulat.ziganshin at gmail.com Wed Dec 3 11:08:00 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Dec 3 11:04:11 2008 Subject: [Haskell-cafe] handles and foreign C functions In-Reply-To: <20081203140921.GD26844@Andrea.Nowhere.net> References: <20081203140921.GD26844@Andrea.Nowhere.net> Message-ID: <199715818.20081203190800@gmail.com> Hello Andrea, Wednesday, December 3, 2008, 5:09:21 PM, you wrote: > How can I pass to printStuff a stdout FILE pointer? afair, "&stdout" syntax used to import variables. it was discussed just a day or two ago :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Wed Dec 3 11:09:52 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Dec 3 11:04:16 2008 Subject: [Haskell-cafe] gmp license == no commercial/closed source haskell software ?? In-Reply-To: <20081203143657.GD16108@scytale.galois.com> References: <4936995E.9050605@gamr7.com> <20081203143657.GD16108@scytale.galois.com> Message-ID: <1926030296.20081203190952@gmail.com> Hello Don, Wednesday, December 3, 2008, 5:36:57 PM, you wrote: >> From my understanding, the gmp is GPL, GHC statically links it on windows. > GMP is *LGPL*. > Supporting this is trivial with a dynamically linked / DLL libgmp. the whole problem is that it links in statically, that reduces license to GPL -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From asandroq at gmail.com Wed Dec 3 10:40:56 2008 From: asandroq at gmail.com (Alex Sandro Queiroz e Silva) Date: Wed Dec 3 11:05:55 2008 Subject: [Haskell-cafe] gmp license == no commercial/closed source haskell software ?? In-Reply-To: <20081203143657.GD16108@scytale.galois.com> References: <4936995E.9050605@gamr7.com> <20081203143657.GD16108@scytale.galois.com> Message-ID: <4936A888.5040008@gmail.com> Hallo, Don Stewart wrote: > > Supporting this is trivial with a dynamically linked / DLL libgmp. With > a statically linked one, it is also possible, since the API calls to > libgmp are specified. > Is it also possible? How? > This shouldn't prevent commercial use -- lots of other companies have > decided this is OK. You just need to be aware of it. > They have decided this is OK as long as they can ship a shared library. Cheers, -alex http://www.ventonegro.org/ From mailing_list at istitutocolli.org Wed Dec 3 11:23:20 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Wed Dec 3 11:16:47 2008 Subject: [Haskell-cafe] handles and foreign C functions In-Reply-To: <199715818.20081203190800@gmail.com> References: <20081203140921.GD26844@Andrea.Nowhere.net> <199715818.20081203190800@gmail.com> Message-ID: <20081203162320.GE26844@Andrea.Nowhere.net> On Wed, Dec 03, 2008 at 07:08:00PM +0300, Bulat Ziganshin wrote: > Hello Andrea, > > Wednesday, December 3, 2008, 5:09:21 PM, you wrote: > > > How can I pass to printStuff a stdout FILE pointer? > > afair, "&stdout" syntax used to import variables. it was discussed > just a day or two ago :) you mean this, I think: foreign import ccall unsafe "&stdout" c_stdout :: Ptr CFile (my fault with the cut&paste of the previous message). This is causing the segmentation fault I was talking about. Thanks, Andrea From bulat.ziganshin at gmail.com Wed Dec 3 11:26:39 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Dec 3 11:20:53 2008 Subject: [Haskell-cafe] handles and foreign C functions In-Reply-To: <20081203162320.GE26844@Andrea.Nowhere.net> References: <20081203140921.GD26844@Andrea.Nowhere.net> <199715818.20081203190800@gmail.com> <20081203162320.GE26844@Andrea.Nowhere.net> Message-ID: <558204400.20081203192639@gmail.com> Hello Andrea, Wednesday, December 3, 2008, 7:23:20 PM, you wrote: either some error in the code (i neevr used this feature) or stdout may be defile by a macro. can you try to define function for it: FILE *out() {return stdout;} > On Wed, Dec 03, 2008 at 07:08:00PM +0300, Bulat Ziganshin wrote: >> Hello Andrea, >> >> Wednesday, December 3, 2008, 5:09:21 PM, you wrote: >> >> > How can I pass to printStuff a stdout FILE pointer? >> >> afair, "&stdout" syntax used to import variables. it was discussed >> just a day or two ago :) > you mean this, I think: > foreign import ccall unsafe "&stdout" c_stdout :: Ptr CFile > (my fault with the cut&paste of the previous message). > This is causing the segmentation fault I was talking about. > Thanks, > Andrea > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From mailing_list at istitutocolli.org Wed Dec 3 11:39:42 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Wed Dec 3 11:33:06 2008 Subject: [Haskell-cafe] handles and foreign C functions In-Reply-To: <558204400.20081203192639@gmail.com> References: <20081203140921.GD26844@Andrea.Nowhere.net> <199715818.20081203190800@gmail.com> <20081203162320.GE26844@Andrea.Nowhere.net> <558204400.20081203192639@gmail.com> Message-ID: <20081203163942.GG26844@Andrea.Nowhere.net> Hello Bulat, On Wed, Dec 03, 2008 at 07:26:39PM +0300, Bulat Ziganshin wrote: > either some error in the code (i neevr used this feature) or stdout > may be defile by a macro. the second you said: /* C89/C99 say they're macros. Make them happy. */ (from stdio.h) > can you try to define function for it: > > FILE *out() {return stdout;} This does the trick. Thank you once again. Andrea From judah.jacobson at gmail.com Wed Dec 3 12:43:18 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Wed Dec 3 12:36:39 2008 Subject: [Haskell-cafe] Problem building HXQ on Mac OS 10.5.5 In-Reply-To: <6E438D44-73F6-4ACD-9BB8-35BEEC3FD836@tobias-kraentzer.de> References: <6E438D44-73F6-4ACD-9BB8-35BEEC3FD836@tobias-kraentzer.de> Message-ID: <6d74b0d20812030943g2b48d7d9yf4d0169e2f5c3ad0@mail.gmail.com> On Tue, Dec 2, 2008 at 9:49 AM, Tobias Kr?ntzer wrote: > Hi, > > I'm new to haskell and wonted to start tinkering a bit with this language, > specifically with HXQ. I have installed ghc with macports. > > Now while building HXQ I get the following error: > > Main.hs:20:9: > Not in scope: type constructor or class `C.SomeException' > > Unfortunately I'm also new to Mac OS X. Before I developed on Linux. > It would be great, if someone could give me a hint. > I think you should be able to build it if you manually download the .tar.gz file from Hackage and then type: runghc Setup configure runghc Setup build runghc Setup install The Control.Exception module was changed in ghc-6.10.1 (specifically, in the base-4 package). HXQ's code assumes that when compiling with ghc-6.10 you're always using base-4; however, that compiler also comes with base-3.0.3 which is a compatibility package providing the same interface as previous versions of ghc. The 'cabal install' program tries to be helpful and selects base-3.0.3 (since HXQ does not specify which to use), causing the above error. I've cc'd the package author on this. A possible fix would be to use the extensible-exceptions package, or otherwise just copy the logic from its .cabal file. -Judah From hpacheco at gmail.com Wed Dec 3 13:03:17 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Wed Dec 3 12:56:38 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <20081203154435.GB7436@berkeley.edu> References: <20081108203244.GA6568@berkeley.edu> <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> Message-ID: <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> yes, I am talking about inserting HTML inside the wiki.Thanks, I will check on that and report back, hugo On Wed, Dec 3, 2008 at 3:44 PM, John MacFarlane wrote: > +++ Hugo Pacheco [Dec 03 08 09:36 ]: > > Good morning, > > I wonder if it is possible to embed regular HTML code inside gitit (on > > 0.3.2) pages, such as java applets like the following. > > = > > 400 ALT = "you should see an instance of GHood here, as an applet"> > > NAME = "eventSource" VALUE ="factHylo.log"> VALUE > > ="150"> > > I am assuming that as a wiki, it is only possible to point to external > > pages. > > Thanks, > > hugo > > Of course you can put any HTML you like in the page template > (template.html). But I assume you are asking about HTML inside the wiki > pages themselves. Although markdown allows embedded HTML, gitit uses > pandoc's > HTML sanitization feature, so things that might be dangerous (like > applets) will be filtered out and replaced by comments. > > You could easily modify the code to remove the santitization feature. > Just change the textToPandoc function so that stateSanitizeHtml is set to > False. > > John > > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081203/e15faf91/attachment.htm From matt at immute.net Wed Dec 3 13:17:59 2008 From: matt at immute.net (Matt Hellige) Date: Wed Dec 3 13:11:20 2008 Subject: [Haskell-cafe] Gluing pipes Message-ID: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> >From time to time, I've wanted to have a more pleasant way of writing point-free compositions of curried functions. One might want to transform both the first and second arguments, for instance, or only the third argument, of a curried function. I've never known a (non-cryptic) way to do this. For example, given: f :: a -> b -> c g :: a1 -> a h :: b2 -> b I'd like to be able to write something like: \ x y -> f (g x) (h y) in a way that is both point-free and applicative. In other words, I'd like to apply a function to "pipes" or transformers rather than to values. Recent posts by Conal Elliott [1,2] got me thinking about this again, and I've found a simple solution. I use two of Conal's combinators: argument = flip (.) result = (.) And now we define: infixr 2 ~> f ~> g = argument f . result g infixl 1 $. ($.) = flip ($) Which lets us write: -- transform both arguments f $. g ~> h ~> id -- transform just the second argument f $. id ~> h ~> id The name ($.) is chosen to indicate that this is (roughly) a composition disguised as an application. The transformer spec to the right of ($.) looks like the type of the function to the left, and consists of a transformer for each argument and one for the result type. Of course, (~>) is right associative, and id can match the entire tail "in bulk", so we can also write something like: f $. g ~> id And of course, each transformer can be a pipeline, so assuming proper types, we can do things like: f $. id ~> (length.snd.unWrap) ~> wrap More details here: http://matt.immute.net/content/pointless-fun Questions: 1. Is there already another well-known way to do this? It seems a common enough problem... 2. Do these particular combinators already exist somewhere with other names? 3. Are there better names for these functions? Thanks! Matt [1] http://conal.net/blog/posts/semantic-editor-combinators/ [2] http://conal.net/blog/posts/prettier-functions-for-wrapping-and-wrapping/ From andrewcoppin at btinternet.com Wed Dec 3 14:53:31 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 3 14:46:54 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <07632D23-064E-40E7-AED5-C6B671EF7EDD@ece.cmu.edu> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> <20081201225102.GA6243@hustlerturf.com> <49359010.8040306@btinternet.com> <07632D23-064E-40E7-AED5-C6B671EF7EDD@ece.cmu.edu> Message-ID: <4936E3BB.9090607@btinternet.com> Brandon S. Allbery KF8NH wrote: > On 2008 Dec 2, at 14:44, Andrew Coppin wrote: >> Regardless, it has been my general experience that almost everything >> obtained from Hackage fails miserably to compile under Windows. >> (IIRC, one package even used a Bash script as part of the build >> process!) I haven't seen similar problems on Linux. (But I don't use >> Linux very often.) About the worst problem there was Gtk2hs being >> confused about some Autoconfig stuff or something... > > > Many packages assume you have the msys / mingw stuff installed on > Windows (if they work at all; those of us who don't develop on Windows > wouldn't really know how to go about being compatible). > According to the Cabal experts, the issue is that Windows doesn't have a "standard" place for keeping header files like the various POSIX environments typically do. That means anything that binds an external C library (i.e., almost all useful Haskell packages) don't easily work on Windows. I'm not sure what the solution to this is... From andrewcoppin at btinternet.com Wed Dec 3 14:57:00 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 3 14:50:20 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <42784f260812022300j1386a482t531087701fc1304a@mail.gmail.com> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> <20081201225102.GA6243@hustlerturf.com> <49359010.8040306@btinternet.com> <42784f260812022300j1386a482t531087701fc1304a@mail.gmail.com> Message-ID: <4936E48C.3040504@btinternet.com> Jason Dusek wrote: > Andrew Coppin wrote: > >> ...it has been my general experience that almost everything >> obtained from Hackage fails miserably to compile under >> Windows. (IIRC, one package even used a Bash script as part of >> the build process!) I haven't seen similar problems on Linux. >> (But I don't use Linux very often.) >> > > I try very hard to make my programs work on Windows; and > indeed, one of things I appreciate about Haskell is how easy > it is to create binaries and packages that are cross platform. > Certainly the one or two "pure Haskell" packages out there (e.g., PureMD5) seem to build without issue. The trouble is that almost all useful Haskell packages are bindings to C libraries, and that varies by platform. :-( > However, the only time I actually use Windows is to build and > test my Haskell packages. Most of the people on this list -- > and I wager, most people on the mailing lists for any open > source programming language -- are working on a NIXalike; we > can work with bug reports, but we can't very well be the > fabled "many eyeballs" on a platform we don't use. Ask not > what your Haskell can do for you, but rather what you can do > for your Haskell :) > As I say, last time I tried this, I'd just failed to build half a dozen other interesting packages, so by the time I'd got to trying to get database access working, I was frustrated to the point of giving up. (The IRC channel is great - but only if the people you need to speak to happen to be there at the exact moment when you ask your question. Apparently I'm in a different timezone to everybody else.) >> About the worst problem there was Gtk2hs being confused about >> some Autoconfig stuff or something... >> > > Well, what else would a package built with GNU toolchain be > confused about? Is there some miraculous language and package > system for it where compiling libraries made with autotools is > just a snap on Windows? > No no - I meant the worst problem _on Linux_ was Gtk2hs getting confused. (It built OK on OpenSuSE, but appears not to like Ubuntu very much.) From coreyoconnor at gmail.com Wed Dec 3 14:57:59 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Wed Dec 3 14:51:20 2008 Subject: [Haskell-cafe] Projects that depend on the vty package? Message-ID: Hello, For further development of the vty package I'm really only paying attention to the requirements that fall out of the Yi project. Are there any other projects that depend on the vty package? In addition, the vty project has it's own wiki: http://trac.haskell.org/vty/ Right now there isn't much information there but it is a great place to send bug reports or enhancement requests if you have them. Cheers, Corey O'Connor From hpacheco at gmail.com Wed Dec 3 15:40:02 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Wed Dec 3 15:33:24 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> References: <20081108203244.GA6568@berkeley.edu> <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> Message-ID: <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> On a different level, I was trying the wiki on my laptop, but have now installed it in a remote server. However, with the same configurations, I can create users but not log in, it simply returns to the front page. It is hosted at http://haskell.di.uminho.pt:8080 It does not seem to be a permissions problem, I gave full permissions to all gitit files and nothing changed. Any idea why? Also being an headache is configuring apache reverse proxy for it: http://haskell.di.uminho.pt/wiki/ hugo On Wed, Dec 3, 2008 at 6:03 PM, Hugo Pacheco wrote: > yes, I am talking about inserting HTML inside the wiki.Thanks, I will > check on that and report back, > > hugo > > > On Wed, Dec 3, 2008 at 3:44 PM, John MacFarlane wrote: > >> +++ Hugo Pacheco [Dec 03 08 09:36 ]: >> > Good morning, >> > I wonder if it is possible to embed regular HTML code inside gitit >> (on >> > 0.3.2) pages, such as java applets like the following. >> > > HEIGHT = >> > 400 ALT = "you should see an instance of GHood here, as an applet"> >> > > NAME = "eventSource" VALUE ="factHylo.log"> > VALUE >> > ="150"> >> > I am assuming that as a wiki, it is only possible to point to >> external >> > pages. >> > Thanks, >> > hugo >> >> Of course you can put any HTML you like in the page template >> (template.html). But I assume you are asking about HTML inside the wiki >> pages themselves. Although markdown allows embedded HTML, gitit uses >> pandoc's >> HTML sanitization feature, so things that might be dangerous (like >> applets) will be filtered out and replaced by comments. >> >> You could easily modify the code to remove the santitization feature. >> Just change the textToPandoc function so that stateSanitizeHtml is set to >> False. >> >> John >> >> > > > -- > www.di.uminho.pt/~hpacheco > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081203/ddc80380/attachment.htm From hpacheco at gmail.com Wed Dec 3 16:29:31 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Wed Dec 3 16:22:54 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> References: <20081108203244.GA6568@berkeley.edu> <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> Message-ID: <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> Solved, just something with my Safari cookies, sorry. On Wed, Dec 3, 2008 at 8:40 PM, Hugo Pacheco wrote: > On a different level, I was trying the wiki on my laptop, but have now > installed it in a remote server. > However, with the same configurations, I can create users but not log in, > it simply returns to the front page. It is hosted at > http://haskell.di.uminho.pt:8080 > > It does not seem to be a permissions problem, I gave full permissions to > all gitit files and nothing changed. > Any idea why? > > Also being an headache is configuring apache reverse proxy for it: > http://haskell.di.uminho.pt/wiki/ > > hugo > > > On Wed, Dec 3, 2008 at 6:03 PM, Hugo Pacheco wrote: > >> yes, I am talking about inserting HTML inside the wiki.Thanks, I will >> check on that and report back, >> >> hugo >> >> >> On Wed, Dec 3, 2008 at 3:44 PM, John MacFarlane wrote: >> >>> +++ Hugo Pacheco [Dec 03 08 09:36 ]: >>> > Good morning, >>> > I wonder if it is possible to embed regular HTML code inside gitit >>> (on >>> > 0.3.2) pages, such as java applets like the following. >>> > >> HEIGHT = >>> > 400 ALT = "you should see an instance of GHood here, as an applet"> >>> >> > NAME = "eventSource" VALUE ="factHylo.log"> >> VALUE >>> > ="150"> >>> > I am assuming that as a wiki, it is only possible to point to >>> external >>> > pages. >>> > Thanks, >>> > hugo >>> >>> Of course you can put any HTML you like in the page template >>> (template.html). But I assume you are asking about HTML inside the wiki >>> pages themselves. Although markdown allows embedded HTML, gitit uses >>> pandoc's >>> HTML sanitization feature, so things that might be dangerous (like >>> applets) will be filtered out and replaced by comments. >>> >>> You could easily modify the code to remove the santitization feature. >>> Just change the textToPandoc function so that stateSanitizeHtml is set to >>> False. >>> >>> John >>> >>> >> >> >> -- >> www.di.uminho.pt/~hpacheco >> > > > > -- > www.di.uminho.pt/~hpacheco > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081203/92074c61/attachment.htm From yuriy.halytskyy at gmail.com Wed Dec 3 17:59:07 2008 From: yuriy.halytskyy at gmail.com (Yuriy) Date: Wed Dec 3 17:51:59 2008 Subject: [Haskell-cafe] library to process zip files In-Reply-To: <20081203225610.GC30047@yhal003-desktop> References: <490C513A.3030200@btinternet.com> <20081101141430.GA4203@zombie.inf.tu-dresden.de> <490C6E9E.9060703@btinternet.com> <20081102175958.GA4564@zombie.inf.tu-dresden.de> <490DF724.3090903@btinternet.com> <221b53ab0811030747v572fe2d7la0d5e2af479d7d10@mail.gmail.com> <221b53ab0811031156g74d962c9j6492436b0ca10ed3@mail.gmail.com> <20081203225610.GC30047@yhal003-desktop> Message-ID: <20081203225907.GD30047@yhal003-desktop> On Thu, Dec 04, 2008 at 11:56:10AM +1300, Yuriy wrote: Hi, Is there any haskell library to work with ZIP file format? Thanks, Yuriy From jefferson.r.heard at gmail.com Wed Dec 3 18:01:59 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Wed Dec 3 17:55:20 2008 Subject: [Haskell-cafe] library to process zip files In-Reply-To: <20081203225907.GD30047@yhal003-desktop> References: <490C513A.3030200@btinternet.com> <20081101141430.GA4203@zombie.inf.tu-dresden.de> <490C6E9E.9060703@btinternet.com> <20081102175958.GA4564@zombie.inf.tu-dresden.de> <490DF724.3090903@btinternet.com> <221b53ab0811030747v572fe2d7la0d5e2af479d7d10@mail.gmail.com> <221b53ab0811031156g74d962c9j6492436b0ca10ed3@mail.gmail.com> <20081203225610.GC30047@yhal003-desktop> <20081203225907.GD30047@yhal003-desktop> Message-ID: <4165d3a70812031501l4573ed55y13ddc9343a904026@mail.gmail.com> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/zip-archive On Wed, Dec 3, 2008 at 5:59 PM, Yuriy wrote: > On Thu, Dec 04, 2008 at 11:56:10AM +1300, Yuriy wrote: > Hi, > > Is there any haskell library to work with ZIP file format? > > Thanks, > Yuriy > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From aeyakovenko at gmail.com Wed Dec 3 18:05:37 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Dec 3 17:58:58 2008 Subject: [Haskell-cafe] is there something special about the Num instance? Message-ID: module Test where --why does this work: data Test = Test class Foo t where foo :: Num v => t -> v -> IO () instance Foo Test where foo _ 1 = print $ "one" foo _ _ = print $ "not one" --but this doesn't? class Bar t where bar :: Foo v => t -> v -> IO () instance Bar Test where bar _ Test = print $ "test" bar _ _ = print $ "not test" From yuriy.halytskyy at gmail.com Wed Dec 3 18:08:35 2008 From: yuriy.halytskyy at gmail.com (Yuriy) Date: Wed Dec 3 18:01:30 2008 Subject: [Haskell-cafe] library to process zip files Message-ID: <20081203230835.GE30047@yhal003-desktop> Almost as fast as typing "proper" google query :) Thanks. On Wed, Dec 03, 2008 at 06:01:59PM -0500, Jeff Heard wrote: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/zip-archive > > On Wed, Dec 3, 2008 at 5:59 PM, Yuriy wrote: > > On Thu, Dec 04, 2008 at 11:56:10AM +1300, Yuriy wrote: > > Hi, > > > > Is there any haskell library to work with ZIP file format? > > > > Thanks, > > Yuriy > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From yuriy.halytskyy at gmail.com Wed Dec 3 18:21:37 2008 From: yuriy.halytskyy at gmail.com (Yuriy) Date: Wed Dec 3 18:14:28 2008 Subject: [Haskell-cafe] is there something special about the Num instance? In-Reply-To: <20081203231708.GF30047@yhal003-desktop> References: <20081203231708.GF30047@yhal003-desktop> Message-ID: <20081203232137.GG30047@yhal003-desktop> Numeric literals are special. Their type is (Num t) => t, so it can belong to any type that is instance of Num. Whereas Test belongs to Test type only so you cannot call bar on any instance of Foo. So your pattern constrains type signature of bar more then it is constrained by class declaration. On Wed, Dec 03, 2008 at 03:05:37PM -0800, Anatoly Yakovenko wrote: > module Test where > --why does this work: > data Test = Test > > class Foo t where > foo :: Num v => t -> v -> IO () > > instance Foo Test where > foo _ 1 = print $ "one" > foo _ _ = print $ "not one" > > --but this doesn't? > > class Bar t where > bar :: Foo v => t -> v -> IO () > > instance Bar Test where > bar _ Test = print $ "test" > bar _ _ = print $ "not test" > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From daniel.is.fischer at web.de Wed Dec 3 18:34:23 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Dec 3 18:25:29 2008 Subject: [Haskell-cafe] is there something special about the Num instance? In-Reply-To: References: Message-ID: <200812040034.26730.daniel.is.fischer@web.de> Am Donnerstag, 4. Dezember 2008 00:05 schrieb Anatoly Yakovenko: > module Test where > --why does this work: > data Test = Test > > class Foo t where > foo :: Num v => t -> v -> IO () > > instance Foo Test where > foo _ 1 = print $ "one" > foo _ _ = print $ "not one" > > --but this doesn't? > > class Bar t where > bar :: Foo v => t -> v -> IO () > > instance Bar Test where > bar _ Test = print $ "test" > bar _ _ = print $ "not test" Because bar has to work for all types which belong to class Foo, but actually uses the type Test. This is what the error message Test.hs:18:10: Couldn't match expected type `v' against inferred type `Test' `v' is a rigid type variable bound by the type signature for `bar' at Test.hs:15:15 In the pattern: Test In the definition of `bar': bar _ Test = print $ "test" In the definition for method `bar' tells you. In the signature of bar, you've said that bar works for all types v which are members of Foo. Test is a monomorphic value of type Test, so it can't have type v for all v which belong to Foo. It doesn't matter that there is so far only the one instance of Foo, there could be others defined in other modules. The first works because the type of 1 in the definition of foo is defaulted to Integer (or whatever you specified in the default declaration). From ryani.spam at gmail.com Wed Dec 3 18:47:19 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Dec 3 18:40:38 2008 Subject: [Haskell-cafe] is there something special about the Num instance? In-Reply-To: References: Message-ID: <2f9b2d30812031547i59b5fe52gd82c893ab0184d0a@mail.gmail.com> Yes; I had a similar question, and it turns out Num is special, or rather, pattern matching on integer literals is special. See the thread http://www.nabble.com/Pattern-matching-on-numbers--td20571034.html The summary is that pattern matching on a literal integer is different than a regular pattern match; in particular: > foo 1 = print "one" > foo _ = print "not one" turns into > foo x = if x == fromInteger 1 then "one" else "not one" whereas > bar Test = print "Test" > bar _ = print "Not Test" turns into > bar x = case x of { Test -> print "Test" ; _ -> print "Not Test" } In the former case, the use of (y == fromInteger 1) means that "foo" works on any argument within the class Num (which requires Eq), whereas in the latter case, the use of the constructor Test directly turns into a requirement for a particular type for "bar". There's no way to get special pattern matching behavior for other types; this overloading is specific to integer literals. -- ryan On Wed, Dec 3, 2008 at 3:05 PM, Anatoly Yakovenko wrote: > module Test where > --why does this work: > data Test = Test > > class Foo t where > foo :: Num v => t -> v -> IO () > > instance Foo Test where > foo _ 1 = print $ "one" > foo _ _ = print $ "not one" > > --but this doesn't? > > class Bar t where > bar :: Foo v => t -> v -> IO () > > instance Bar Test where > bar _ Test = print $ "test" > bar _ _ = print $ "not test" > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From hpacheco at gmail.com Wed Dec 3 19:04:19 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Wed Dec 3 18:57:39 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> References: <20081108203244.GA6568@berkeley.edu> <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> Message-ID: <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> Hmm, I think I finally see the real problem. At some point when logged in, the session expires and the wiki prompts again for the login information. However, the cookies still assume we are logged in and do not allow me to log in again. The solution is to remove the cookies for the wiki server. I think this is some kind of bug with the session state. Regards, hugo On Wed, Dec 3, 2008 at 9:29 PM, Hugo Pacheco wrote: > Solved, just something with my Safari cookies, sorry. > > > On Wed, Dec 3, 2008 at 8:40 PM, Hugo Pacheco wrote: > >> On a different level, I was trying the wiki on my laptop, but have now >> installed it in a remote server. >> However, with the same configurations, I can create users but not log in, >> it simply returns to the front page. It is hosted at >> http://haskell.di.uminho.pt:8080 >> >> It does not seem to be a permissions problem, I gave full permissions to >> all gitit files and nothing changed. >> Any idea why? >> >> Also being an headache is configuring apache reverse proxy for it: >> http://haskell.di.uminho.pt/wiki/ >> >> hugo >> >> >> On Wed, Dec 3, 2008 at 6:03 PM, Hugo Pacheco wrote: >> >>> yes, I am talking about inserting HTML inside the wiki.Thanks, I will >>> check on that and report back, >>> >>> hugo >>> >>> >>> On Wed, Dec 3, 2008 at 3:44 PM, John MacFarlane wrote: >>> >>>> +++ Hugo Pacheco [Dec 03 08 09:36 ]: >>>> > Good morning, >>>> > I wonder if it is possible to embed regular HTML code inside gitit >>>> (on >>>> > 0.3.2) pages, such as java applets like the following. >>>> > >>> HEIGHT = >>>> > 400 ALT = "you should see an instance of GHood here, as an applet"> >>>> >>> > NAME = "eventSource" VALUE ="factHylo.log"> >>> VALUE >>>> > ="150"> >>>> > I am assuming that as a wiki, it is only possible to point to >>>> external >>>> > pages. >>>> > Thanks, >>>> > hugo >>>> >>>> Of course you can put any HTML you like in the page template >>>> (template.html). But I assume you are asking about HTML inside the wiki >>>> pages themselves. Although markdown allows embedded HTML, gitit uses >>>> pandoc's >>>> HTML sanitization feature, so things that might be dangerous (like >>>> applets) will be filtered out and replaced by comments. >>>> >>>> You could easily modify the code to remove the santitization feature. >>>> Just change the textToPandoc function so that stateSanitizeHtml is set >>>> to >>>> False. >>>> >>>> John >>>> >>>> >>> >>> >>> -- >>> www.di.uminho.pt/~hpacheco >>> >> >> >> >> -- >> www.di.uminho.pt/~hpacheco >> > > > > -- > www.di.uminho.pt/~hpacheco > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081204/240648d4/attachment.htm From judah.jacobson at gmail.com Wed Dec 3 19:07:00 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Wed Dec 3 19:00:20 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <4936E3BB.9090607@btinternet.com> References: <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> <20081201225102.GA6243@hustlerturf.com> <49359010.8040306@btinternet.com> <07632D23-064E-40E7-AED5-C6B671EF7EDD@ece.cmu.edu> <4936E3BB.9090607@btinternet.com> Message-ID: <6d74b0d20812031607w71a390abp521ec2b6b10965fd@mail.gmail.com> On Wed, Dec 3, 2008 at 11:53 AM, Andrew Coppin wrote: > Brandon S. Allbery KF8NH wrote: >> >> On 2008 Dec 2, at 14:44, Andrew Coppin wrote: >>> >>> Regardless, it has been my general experience that almost everything >>> obtained from Hackage fails miserably to compile under Windows. (IIRC, one >>> package even used a Bash script as part of the build process!) I haven't >>> seen similar problems on Linux. (But I don't use Linux very often.) About >>> the worst problem there was Gtk2hs being confused about some Autoconfig >>> stuff or something... >> >> >> Many packages assume you have the msys / mingw stuff installed on Windows >> (if they work at all; those of us who don't develop on Windows wouldn't >> really know how to go about being compatible). >> > > According to the Cabal experts, the issue is that Windows doesn't have a > "standard" place for keeping header files like the various POSIX > environments typically do. That means anything that binds an external C > library (i.e., almost all useful Haskell packages) don't easily work on > Windows. I'm not sure what the solution to this is... Have you tried passing the --extra-include-dirs and --extra-lib-dirs arguments to 'cabal install'? On OS X, that's how I deal with the macports package manager which puts all library files under /opt/local. I've found the process pretty painless. -Judah From aeyakovenko at gmail.com Wed Dec 3 19:08:47 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Dec 3 19:02:07 2008 Subject: [Haskell-cafe] is there something special about the Num instance? In-Reply-To: <2f9b2d30812031547i59b5fe52gd82c893ab0184d0a@mail.gmail.com> References: <2f9b2d30812031547i59b5fe52gd82c893ab0184d0a@mail.gmail.com> Message-ID: Thanks for your help. On Wed, Dec 3, 2008 at 3:47 PM, Ryan Ingram wrote: > Yes; I had a similar question, and it turns out Num is special, or > rather, pattern matching on integer literals is special. See the > thread > > http://www.nabble.com/Pattern-matching-on-numbers--td20571034.html > > The summary is that pattern matching on a literal integer is different > than a regular pattern match; in particular: > >> foo 1 = print "one" >> foo _ = print "not one" > > turns into > >> foo x = if x == fromInteger 1 then "one" else "not one" > > whereas > >> bar Test = print "Test" >> bar _ = print "Not Test" > > turns into > >> bar x = case x of { Test -> print "Test" ; _ -> print "Not Test" } > > In the former case, the use of (y == fromInteger 1) means that "foo" > works on any argument within the class Num (which requires Eq), > whereas in the latter case, the use of the constructor Test directly > turns into a requirement for a particular type for "bar". > > There's no way to get special pattern matching behavior for other > types; this overloading is specific to integer literals. > > -- ryan > > On Wed, Dec 3, 2008 at 3:05 PM, Anatoly Yakovenko wrote: >> module Test where >> --why does this work: >> data Test = Test >> >> class Foo t where >> foo :: Num v => t -> v -> IO () >> >> instance Foo Test where >> foo _ 1 = print $ "one" >> foo _ _ = print $ "not one" >> >> --but this doesn't? >> >> class Bar t where >> bar :: Foo v => t -> v -> IO () >> >> instance Bar Test where >> bar _ Test = print $ "test" >> bar _ _ = print $ "not test" >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From aeyakovenko at gmail.com Wed Dec 3 20:03:19 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Dec 3 19:56:40 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> References: <20081108203244.GA6568@berkeley.edu> <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> Message-ID: This is pretty cool. I was wondering how much work would it be for gitit to be able to use markdown from the comment sections in source files? It would be a really good way to manage documentation. Basically I would like to be able to point gitit at an existing git repo, and have it provide a wiki interface to all the documentation so developers can view and modify it. Thanks, Anatoly 2008/12/3 Hugo Pacheco : > Hmm, I think I finally see the real problem. > At some point when logged in, the session expires and the wiki prompts again > for the login information. However, the cookies still assume we are logged > in and do not allow me to log in again. > The solution is to remove the cookies for the wiki server. > I think this is some kind of bug with the session state. > Regards, > hugo > On Wed, Dec 3, 2008 at 9:29 PM, Hugo Pacheco wrote: >> >> Solved, just something with my Safari cookies, sorry. >> >> On Wed, Dec 3, 2008 at 8:40 PM, Hugo Pacheco wrote: >>> >>> On a different level, I was trying the wiki on my laptop, but have now >>> installed it in a remote server. >>> However, with the same configurations, I can create users but not log in, >>> it simply returns to the front page. It is hosted >>> at http://haskell.di.uminho.pt:8080 >>> It does not seem to be a permissions problem, I gave full permissions to >>> all gitit files and nothing changed. >>> Any idea why? >>> Also being an headache is configuring apache reverse proxy for >>> it: http://haskell.di.uminho.pt/wiki/ >>> hugo >>> >>> On Wed, Dec 3, 2008 at 6:03 PM, Hugo Pacheco wrote: >>>> >>>> yes, I am talking about inserting HTML inside the wiki. >>>> Thanks, I will check on that and report back, >>>> hugo >>>> >>>> On Wed, Dec 3, 2008 at 3:44 PM, John MacFarlane >>>> wrote: >>>>> >>>>> +++ Hugo Pacheco [Dec 03 08 09:36 ]: >>>>> > Good morning, >>>>> > I wonder if it is possible to embed regular HTML code inside gitit >>>>> > (on >>>>> > 0.3.2) pages, such as java applets like the following. >>>>> > >>>> > HEIGHT = >>>>> > 400 ALT = "you should see an instance of GHood here, as an >>>>> > applet"> >>>> > NAME = "eventSource" VALUE ="factHylo.log"> >>>> > VALUE >>>>> > ="150"> >>>>> > I am assuming that as a wiki, it is only possible to point to >>>>> > external >>>>> > pages. >>>>> > Thanks, >>>>> > hugo >>>>> >>>>> Of course you can put any HTML you like in the page template >>>>> (template.html). But I assume you are asking about HTML inside the >>>>> wiki >>>>> pages themselves. Although markdown allows embedded HTML, gitit uses >>>>> pandoc's >>>>> HTML sanitization feature, so things that might be dangerous (like >>>>> applets) will be filtered out and replaced by comments. >>>>> >>>>> You could easily modify the code to remove the santitization feature. >>>>> Just change the textToPandoc function so that stateSanitizeHtml is set >>>>> to >>>>> False. >>>>> >>>>> John >>>>> >>>> >>>> >>>> >>>> -- >>>> www.di.uminho.pt/~hpacheco >>> >>> >>> >>> -- >>> www.di.uminho.pt/~hpacheco >> >> >> >> -- >> www.di.uminho.pt/~hpacheco > > > > -- > www.di.uminho.pt/~hpacheco > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jgm at berkeley.edu Wed Dec 3 20:54:35 2008 From: jgm at berkeley.edu (John MacFarlane) Date: Wed Dec 3 20:47:57 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: References: <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081109214059.GA13552@berkeley.edu> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> Message-ID: <20081204015435.GA10586@berkeley.edu> +++ Anatoly Yakovenko [Dec 03 08 17:03 ]: > This is pretty cool. I was wondering how much work would it be for > gitit to be able to use markdown from the comment sections in source > files? It would be a really good way to manage documentation. > > Basically I would like to be able to point gitit at an existing git > repo, and have it provide a wiki interface to all the documentation so > developers can view and modify it. You can do something like that now. You can specify the repository directory in a configuration file. Anything in the repository (even in subdirectories) with a ".page" extension will be served up as a wiki page. So you'd have to use a ".page" extension for your markdown documentation. Everything else in the repository will appear in the index. Source code files will be automatically syntax-highlighted, and you can even view history and diffs through the wiki interface. But I guess what you want is for the documentation to be in comments in the source files themselves, not in separate files. I'm not sure how to do that -- would the idea be to show just the documentation, perhaps marked off with some special notation, and not the source? But then we lose a nice feature, the ability to view source files. I'm open to ideas. Soon, gitit will contain support for pages in markdownish literate Haskell, which might be the best of both worlds for Haskell projects. (They'd still need the .page extension, since some .lhs files are LaTeX lhs, but one could use hard links, or there could be a configuration option to treat .lhs files as wiki pages.) John From aeyakovenko at gmail.com Wed Dec 3 21:05:15 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Dec 3 20:58:34 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <20081204015435.GA10586@berkeley.edu> References: <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> <20081204015435.GA10586@berkeley.edu> Message-ID: On Wed, Dec 3, 2008 at 5:54 PM, John MacFarlane wrote: > +++ Anatoly Yakovenko [Dec 03 08 17:03 ]: >> This is pretty cool. I was wondering how much work would it be for >> gitit to be able to use markdown from the comment sections in source >> files? It would be a really good way to manage documentation. >> >> Basically I would like to be able to point gitit at an existing git >> repo, and have it provide a wiki interface to all the documentation so >> developers can view and modify it. > > You can do something like that now. You can specify the repository > directory in a configuration file. Anything in the repository (even > in subdirectories) with a ".page" extension will be served up as a > wiki page. So you'd have to use a ".page" extension for your markdown > documentation. Everything else in the repository will appear in the > index. Source code files will be automatically syntax-highlighted, and > you can even view history and diffs through the wiki interface. cool. Does it add any other files to the reposoitory? Could you use it over a read only one? > But I guess what you want is for the documentation to be in comments > in the source files themselves, not in separate files. I'm not sure > how to do that -- would the idea be to show just the documentation, > perhaps marked off with some special notation, and not the source? > But then we lose a nice feature, the ability to view source files. > I'm open to ideas. I was thinking it would show both the documentation and the source, but have the documentation as the editable part of the page. Do you think that's possible? Or it could parse out the documentation and show 2 dynamically generated pages, one for just the docs and one for the source. But i think it would be useful to be able to see the documentation in the context of the source that its referring to. Unfortunately I am not a web guy, so i have no idea how hard any of this would be :). From ramsdell0 at gmail.com Wed Dec 3 21:06:09 2008 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Wed Dec 3 20:59:29 2008 Subject: [Haskell-cafe] GHC on Fedora 10 - getMBlock: mmap: Permission denied In-Reply-To: References: <3e1162e60812020648x556b53a0n3cb4659f3ca6883d@mail.gmail.com> <714866820.20081202184210@gmail.com> Message-ID: <7687290b0812031806r5f71f538vc5fff142cee03a99@mail.gmail.com> I had fun with SELinux when using Haskell for CGI programs. The default SELinux policy forbids CGI programs that execute code in their data segment. I had to write a policy module that allowed httpd_sys_script_t self:process execmem. Oh joy. John From hpacheco at gmail.com Wed Dec 3 21:06:37 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Wed Dec 3 20:59:57 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <20081204015435.GA10586@berkeley.edu> References: <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <37F163D2-8528-416B-84BF-DAFFC9FF5E77@eidhof.nl> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> <20081204015435.GA10586@berkeley.edu> Message-ID: <7b92c2840812031806l17452c9dx48040d7867cbb2dd@mail.gmail.com> I think that Anatoly was suggestion a bridge between markdown and haddock syntax. Of course gitit would read haddock-documented sources and generate different results than haddock itself (showing highlighted source code is the most significant). Being practical, this is very close to the markdownish literate haskell you are suggesting. hugo On Thu, Dec 4, 2008 at 1:54 AM, John MacFarlane wrote: > +++ Anatoly Yakovenko [Dec 03 08 17:03 ]: > > This is pretty cool. I was wondering how much work would it be for > > gitit to be able to use markdown from the comment sections in source > > files? It would be a really good way to manage documentation. > > > > Basically I would like to be able to point gitit at an existing git > > repo, and have it provide a wiki interface to all the documentation so > > developers can view and modify it. > > You can do something like that now. You can specify the repository > directory in a configuration file. Anything in the repository (even > in subdirectories) with a ".page" extension will be served up as a > wiki page. So you'd have to use a ".page" extension for your markdown > documentation. Everything else in the repository will appear in the > index. Source code files will be automatically syntax-highlighted, and > you can even view history and diffs through the wiki interface. > > But I guess what you want is for the documentation to be in comments > in the source files themselves, not in separate files. I'm not sure > how to do that -- would the idea be to show just the documentation, > perhaps marked off with some special notation, and not the source? > But then we lose a nice feature, the ability to view source files. > I'm open to ideas. > > Soon, gitit will contain support for pages in markdownish literate > Haskell, which might be the best of both worlds for Haskell projects. > (They'd still need the .page extension, since some .lhs files are > LaTeX lhs, but one could use hard links, or there could be a > configuration option to treat .lhs files as wiki pages.) > > John > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081204/0e6344f7/attachment.htm From aeyakovenko at gmail.com Wed Dec 3 21:10:57 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Dec 3 21:04:16 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: <7b92c2840812031806l17452c9dx48040d7867cbb2dd@mail.gmail.com> References: <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <7b92c2840812030136t525ac1fcic84dd500489d6949@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> <20081204015435.GA10586@berkeley.edu> <7b92c2840812031806l17452c9dx48040d7867cbb2dd@mail.gmail.com> Message-ID: > Being practical, this is very close to the markdownish literate haskell you > are suggesting. > hugo yea, i agree. But is there any way to generalize this to non haskell projects? From dons at galois.com Wed Dec 3 21:47:48 2008 From: dons at galois.com (Don Stewart) Date: Wed Dec 3 21:41:04 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <4936E48C.3040504@btinternet.com> References: <492DC16E.8050606@btinternet.com> <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com> <49310A6F.7010809@btinternet.com> <20081129192715.GB30881@scytale.galois.com> <49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com> <20081201225102.GA6243@hustlerturf.com> <49359010.8040306@btinternet.com> <42784f260812022300j1386a482t531087701fc1304a@mail.gmail.com> <4936E48C.3040504@btinternet.com> Message-ID: <20081204024748.GA17733@scytale.galois.com> andrewcoppin: > Jason Dusek wrote: > >Andrew Coppin wrote: > > > >>...it has been my general experience that almost everything > >>obtained from Hackage fails miserably to compile under > >>Windows. (IIRC, one package even used a Bash script as part of > >>the build process!) I haven't seen similar problems on Linux. > >>(But I don't use Linux very often.) > >> > > > > I try very hard to make my programs work on Windows; and > > indeed, one of things I appreciate about Haskell is how easy > > it is to create binaries and packages that are cross platform. > > > > Certainly the one or two "pure Haskell" packages out there (e.g., > PureMD5) seem to build without issue. The trouble is that almost all > useful Haskell packages are bindings to C libraries, and that varies by > platform. :-( > > > However, the only time I actually use Windows is to build and > > test my Haskell packages. Most of the people on this list -- > > and I wager, most people on the mailing lists for any open > > source programming language -- are working on a NIXalike; we > > can work with bug reports, but we can't very well be the > > fabled "many eyeballs" on a platform we don't use. Ask not > > what your Haskell can do for you, but rather what you can do > > for your Haskell :) > > > > As I say, last time I tried this, I'd just failed to build half a dozen > other interesting packages, so by the time I'd got to trying to get > database access working, I was frustrated to the point of giving up. > Do you mail the maintainers when there's a bulid failure? There's around 1000 packages on hackage now, and we don't have a build farm, so you can make a real difference by mailing authors when their package fails on windows. -- Don From jason.dusek at gmail.com Thu Dec 4 01:07:08 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Dec 4 01:00:31 2008 Subject: [Haskell-cafe] gmp license == no commercial/closed source haskell software ?? In-Reply-To: <1926030296.20081203190952@gmail.com> References: <4936995E.9050605@gamr7.com> <20081203143657.GD16108@scytale.galois.com> <1926030296.20081203190952@gmail.com> Message-ID: <42784f260812032207j9b81afeocfdccf66f67f8e68@mail.gmail.com> Bulat Ziganshin wrote: > Don wrote: > > Lionel wrote: > > > From my understanding, the gmp is GPL, GHC statically > > > links it on windows. > > > > GMP is *LGPL*. > > > > Supporting this is trivial with a dynamically linked / DLL > > libgmp. > > the whole problem is that it links in statically, that reduces > license to GPL Jonathan Cast suggests earlier that there is some wiggle room allowed in 4/(d), even for statically linked programs: d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. At first glance, (0) would seem to apply to a statically linked application; and it appears damning. However: The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. The latter definition admits object code and this seems to be in line with what Cast is saying. The former definition is for the actual source code that must be included -- it is somewhat vague. If an application relies heavily on multi-precision arithmetic, even through adapter classes, is everything in it based on the "Linked Version"? -- _jsn From john at repetae.net Thu Dec 4 03:50:29 2008 From: john at repetae.net (John Meacham) Date: Thu Dec 4 03:43:47 2008 Subject: [Haskell-cafe] manipulating predicate formulae In-Reply-To: References: Message-ID: <20081204085028.GC18561@sliver.repetae.net> I have no idea if it is relevant, but I wrote a tiny proof assistant for a hilbert style first order logic the other day. http://repetae.net/Hilbert.hs set hasUnicode to False at the top if your terminal doesn't support unicode. fun what one can do in a few hundred lines of haskell.. :) heres the cheat sheet: ---- stack operations ---- 0 duplicate top of lemma stack 1-9 move the specified formula to the top of the stack shift A-Z copy the specified formula from the theorem list to the top of the stack - delete top of lemma stack p promote the top of the lemma stack to a theorem ---- rules of inference ---- d (degeneralize) replace a quantifier with an unbound term g (generalize) universally quantify all unbound terms m use modus pones to apply the top of the stack to the second item in the stack ---- utilities ---- h show this help u undo last operation ! quit John -- John Meacham - ?repetae.net?john? From immanuel.normann at googlemail.com Thu Dec 4 06:44:23 2008 From: immanuel.normann at googlemail.com (Immanuel Normann) Date: Thu Dec 4 06:37:42 2008 Subject: [Haskell-cafe] manipulating predicate formulae In-Reply-To: References: Message-ID: <92952f860812040344y2d15f74dsc6442943318f2808@mail.gmail.com> Hi Ganesh, manipulating predicate formulae was a central part of my PhD research. I implemented some normalization and standarcization functions in Haskell - inspired by term rewriting (like normalization to Boolean ring representation) as well as (as far as I know) novell ideas (standardization of quantified formulae w.r.t associativity and commutativity). If you are interested in that stuff I am pleased to provide you with more information. May be you can describe in more detail what you are looking for. Best, Immanuel 2008/11/30 Ganesh Sittampalam > Hi, > > Are there any Haskell libraries around for manipulating predicate formulae? > I had a look on hackage but couldn't spot anything. > > I am generating complex expressions that I'd like some programmatic help in > simplifying. > > Cheers, > > Ganesh > _______________________________________________ > 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/20081204/d10e453e/attachment.htm From tobias.bexelius at avalanchestudios.se Thu Dec 4 07:31:24 2008 From: tobias.bexelius at avalanchestudios.se (Tobias Bexelius) Date: Thu Dec 4 07:24:45 2008 Subject: [Haskell-cafe] ANN: "Real World Haskell", now shipping In-Reply-To: <6d74b0d20812031607w71a390abp521ec2b6b10965fd@mail.gmail.com> References: <42784f260811282134l36e0043fo4424f775cd67a8b5@mail.gmail.com><49310A6F.7010809@btinternet.com><20081129192715.GB30881@scytale.galois.com><49340BDB.5050604@complete.org> <49345E3C.6090002@btinternet.com><20081201225102.GA6243@hustlerturf.com><49359010.8040306@btinternet.com><07632D23-064E-40E7-AED5-C6B671EF7EDD@ece.cmu.edu><4936E3BB.9090607@btinternet.com> <6d74b0d20812031607w71a390abp521ec2b6b10965fd@mail.gmail.com> Message-ID: <698E8783CC407F4EB0DC9E994B6D4540E1E48F@nut.avalanchestudios.se> An even more painless way to do it is to edit the .cabal file (or just cabal on Windows) in the cabal user directory (somwhere under the AppData folder on windows), to have default values for extra-include-dirs and extra-lib-dirs. Then you don't need to enter them explicitly every time you use cabal. /Tobias -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Judah Jacobson Sent: den 4 december 2008 01:07 To: Andrew Coppin Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] ANN: "Real World Haskell", now shipping On Wed, Dec 3, 2008 at 11:53 AM, Andrew Coppin wrote: > Brandon S. Allbery KF8NH wrote: >> >> On 2008 Dec 2, at 14:44, Andrew Coppin wrote: >>> >>> Regardless, it has been my general experience that almost everything >>> obtained from Hackage fails miserably to compile under Windows. >>> (IIRC, one package even used a Bash script as part of the build >>> process!) I haven't seen similar problems on Linux. (But I don't use >>> Linux very often.) About the worst problem there was Gtk2hs being >>> confused about some Autoconfig stuff or something... >> >> >> Many packages assume you have the msys / mingw stuff installed on >> Windows (if they work at all; those of us who don't develop on >> Windows wouldn't really know how to go about being compatible). >> > > According to the Cabal experts, the issue is that Windows doesn't have > a "standard" place for keeping header files like the various POSIX > environments typically do. That means anything that binds an external > C library (i.e., almost all useful Haskell packages) don't easily work > on Windows. I'm not sure what the solution to this is... Have you tried passing the --extra-include-dirs and --extra-lib-dirs arguments to 'cabal install'? On OS X, that's how I deal with the macports package manager which puts all library files under /opt/local. I've found the process pretty painless. -Judah _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From nominolo at googlemail.com Thu Dec 4 09:48:55 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Thu Dec 4 09:42:13 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc In-Reply-To: References: <7b92c2840811091241r528cbcf8q221092ec61e67b79@mail.gmail.com> <20081203154435.GB7436@berkeley.edu> <7b92c2840812031003s53787a0clc57320f9f1c765e1@mail.gmail.com> <7b92c2840812031240l1cca4cb1mc237aa51f91c418a@mail.gmail.com> <7b92c2840812031329s6f474111of94d3e99da5184a5@mail.gmail.com> <7b92c2840812031604l417a1247xfd86437082bced8f@mail.gmail.com> <20081204015435.GA10586@berkeley.edu> <7b92c2840812031806l17452c9dx48040d7867cbb2dd@mail.gmail.com> Message-ID: <916b84820812040648te9b1e9dq71fc8fc3ecce4515@mail.gmail.com> Conal suggested to allow markdown/pandoc as the highlighting format for Haddock, I liked the idea, but many didn't. I guess the only workable solution would be to extend haddock to allow using an external plugin to parse the actual formatting, stripping out leading markers and somehow dealing with Haddock link markup. 2008/12/4 Anatoly Yakovenko : >> Being practical, this is very close to the markdownish literate haskell you >> are suggesting. >> hugo > > yea, i agree. But is there any way to generalize this to non haskell projects? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Push the envelope. Watch it bend. From solistic at gmx.net Thu Dec 4 11:55:34 2008 From: solistic at gmx.net (Sol) Date: Thu Dec 4 11:48:54 2008 Subject: [Haskell-cafe] Building "plugins" from Hackage Message-ID: <49380B86.9060309@gmx.net> Hello List, when I try to install the package "plugins" with cabal i get the following error. cabal: dependencies conflict: ghc-6.8.3 requires Cabal ==1.2.4.0 however Cabal-1.2.4.0 was excluded because plugins-1.3.1 requires Cabal ==1.4.* Is there a way to resolve this? Any ideas? Sol. From dpiponi at gmail.com Thu Dec 4 12:19:27 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Thu Dec 4 12:12:45 2008 Subject: [Haskell-cafe] Gluing pipes In-Reply-To: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> Message-ID: <625b74080812040919y3caa808di65ae6a1313c1464d@mail.gmail.com> On Wed, Dec 3, 2008 at 10:17 AM, Matt Hellige wrote: > >From time to time, I've wanted to have a more pleasant way of writing > point-free compositions of curried functions. > I'd like to be able to write something like: > \ x y -> f (g x) (h y) This particular composition of f with g and h is an example of composition in what mathematicians call an operad. I think operads glue things just how you want. Unfortunately (1) I don't think mathematicians have great notation for it either and (2) it's hard to combine operads with currying because they rely on having a well defined notion of the number of arguments of a function. -- Dan From niklas.broberg at gmail.com Thu Dec 4 13:04:25 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Thu Dec 4 12:57:44 2008 Subject: [Haskell-cafe] ANNOUNCE: haskell-src-exts 0.4.4 Message-ID: Fellow Haskelleers, it is my pleasure to announce the new release of the haskell-src-exts package, version 0.4.4: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts-0.4.4 darcs get http://code.haskell.org/HSP/haskell-src-exts The new feature in this release is support for pragmas. haskell-src-exts-0.4.4 supports all pragmas supported by GHC, with the exception of option-level pragmas (LANGUAGE, OPTIONS_GHC etc) that appear before the module header. The reason these are not yet supported is simply time, there's no real difficulty involved in supporting them too and I will surely get there eventually. 0.4.4 is backwards incompatible with 0.4.3 for two constructors: * The Module constructor (:: Module) now has an extra argument of type 'Maybe WarningText', used for deprecated modules. * The ImportDecl constructor (:: ImportDecl) now has an extra argument of type Bool, stating whether the SOURCE pragma has been used for the import. The full list of pragmas supported by 0.4.4 is: SOURCE, RULES, DEPRECATED, WARNING, INLINE, NOINLINE, SPECIALISE, CORE, SCC, GENERATED and UNPACK. Cheers and Happy Haskelling, /Niklas From matt at immute.net Thu Dec 4 13:07:06 2008 From: matt at immute.net (Matt Hellige) Date: Thu Dec 4 13:00:30 2008 Subject: [Haskell-cafe] Gluing pipes In-Reply-To: <625b74080812040919y3caa808di65ae6a1313c1464d@mail.gmail.com> References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> <625b74080812040919y3caa808di65ae6a1313c1464d@mail.gmail.com> Message-ID: <5959041b0812041007i42692d4cl53475113aa216c6a@mail.gmail.com> On Thu, Dec 4, 2008 at 11:19 AM, Dan Piponi wrote: > On Wed, Dec 3, 2008 at 10:17 AM, Matt Hellige wrote: >> >From time to time, I've wanted to have a more pleasant way of writing >> point-free compositions of curried functions. > >> I'd like to be able to write something like: >> \ x y -> f (g x) (h y) > > This particular composition of f with g and h is an example of > composition in what mathematicians call an operad. I think operads > glue things just how you want. Unfortunately (1) I don't think > mathematicians have great notation for it either and (2) it's hard to > combine operads with currying because they rely on having a well > defined notion of the number of arguments of a function. Yes, of course I should have mentioned operads! I've thought of operads in connection with this puzzle before (and I seem to remember a recent post from you on the subject), but this time around, it slipped my mind... Thanks for the reminder! Something like operadic composition for curried functions is exactly what I want to define, and I agree that your (1) and (2) are exactly the sticking points. I'm relatively happy with what I've come up with so far, but I do still wonder if it's possible to do better. An alternative approach would be to define an Operad type class, and attempt to coax curried functions into and out of an instance as needed. I hesitate to propose that it's impossible, but I guess it would take type class hacking beyond my abilities in any case. We could imagine being able to write something like: f [g, h] and I think this is the route you took in your blog post? But of course your way only works for uncurried functions, right? And there's a bit of boilerplate? I also believe that this approach would leave at least some arity checking to runtime, which I would consider a shortcoming. Perhaps it would be possible to overcome this with length-indexed lists? Finally, there's a further disadvantage to both of these approaches: it seems to me that neither approach allows us to "cross pipes". For instance, we can't define flip using these techniques, or any "deep flip": \ x y z -> f x z y Is it true in general that operads cannot express pipe-crossing compositions? Or is it just a shortcoming of this particular implementation? Of course this is getting farther afield, and I don't believe that my approach can express this either. Anyway I'd still love to know the answers the questions in my last email, as well as the new questions posed in this one. ;) Thanks for taking the time! Matt From waldmann at imn.htwk-leipzig.de Thu Dec 4 13:10:52 2008 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Thu Dec 4 13:04:19 2008 Subject: [Haskell-cafe] Re: Gluing pipes References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> <625b74080812040919y3caa808di65ae6a1313c1464d@mail.gmail.com> Message-ID: > > I'd like to be able to write something like: > > \ x y -> f (g x) (h y) > I don't think > mathematicians have great notation for it either Well, there is Combinatory Logic. http://www.haskell.org/haskellwiki/Combinatory_logic J.W. From matt at immute.net Thu Dec 4 13:21:03 2008 From: matt at immute.net (Matt Hellige) Date: Thu Dec 4 13:14:21 2008 Subject: [Haskell-cafe] Gluing pipes In-Reply-To: <5959041b0812041007i42692d4cl53475113aa216c6a@mail.gmail.com> References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> <625b74080812040919y3caa808di65ae6a1313c1464d@mail.gmail.com> <5959041b0812041007i42692d4cl53475113aa216c6a@mail.gmail.com> Message-ID: <5959041b0812041021h18a5889i270ed99712bca3ee@mail.gmail.com> On Thu, Dec 4, 2008 at 12:07 PM, Matt Hellige wrote: > > Finally, there's a further disadvantage to both of these approaches: > it seems to me that neither approach allows us to "cross pipes". For > instance, we can't define flip using these techniques, or any "deep > flip": > \ x y z -> f x z y > Is it true in general that operads cannot express pipe-crossing > compositions? Or is it just a shortcoming of this particular > implementation? Of course this is getting farther afield, and I don't > believe that my approach can express this either. > This is not exactly true. It's possible in my scheme to express a deep flip, as long as it's the last thing you want to do: \ f x y z -> f x z y == id ~> flip It's not clear to me whether your operad class can express this (or whether operads in general can express this), or whether my scheme can express more general permutations of arguments. Matt From dpiponi at gmail.com Thu Dec 4 13:52:04 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Thu Dec 4 13:45:21 2008 Subject: [Haskell-cafe] Gluing pipes In-Reply-To: <5959041b0812041021h18a5889i270ed99712bca3ee@mail.gmail.com> References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> <625b74080812040919y3caa808di65ae6a1313c1464d@mail.gmail.com> <5959041b0812041007i42692d4cl53475113aa216c6a@mail.gmail.com> <5959041b0812041021h18a5889i270ed99712bca3ee@mail.gmail.com> Message-ID: <625b74080812041052o4d9ca963y3d16d577f72bf569@mail.gmail.com> On Thu, Dec 4, 2008 at 10:21 AM, Matt Hellige wrote: > \ f x y z -> f x z y == id ~> flip > It's not clear to me whether your operad class can express this (or > whether operads in general can express this) There exists an operad that can (at the cost of even more notation), but you're right that the specific operad that I implemented can't. Actually, if you look at the papers, mathematicians do have a perfectly good notation for this, and it'd be cool if there were a programming language that supported it well: drawing diagrams! Johannes Waldmann said: > Well, there is Combinatory Logic. But it's not known for its ease of use :-) -- Dan From haskell at list.mightyreason.com Thu Dec 4 14:01:14 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Thu Dec 4 13:54:48 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: <493828FA.5030906@list.mightyreason.com> Niklas Broberg wrote: > Fellow Haskelleers, > > it is my pleasure to announce the new release of the haskell-src-exts > package, version 0.4.4: > The full list of pragmas supported by 0.4.4 is: SOURCE, RULES, > DEPRECATED, WARNING, INLINE, NOINLINE, SPECIALISE, CORE, SCC, > GENERATED and UNPACK. Ah, excellent. The hprotoc program generates possibly mutually recursive modules and when it does these need fixing up by hand to add SOURCE pragmas and boot files. I could use your new package to automatically break the recursion. Interesting. Thanks, Chris From matt at immute.net Thu Dec 4 15:59:52 2008 From: matt at immute.net (Matt Hellige) Date: Thu Dec 4 15:53:10 2008 Subject: [Haskell-cafe] Gluing pipes In-Reply-To: <625b74080812041052o4d9ca963y3d16d577f72bf569@mail.gmail.com> References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> <625b74080812040919y3caa808di65ae6a1313c1464d@mail.gmail.com> <5959041b0812041007i42692d4cl53475113aa216c6a@mail.gmail.com> <5959041b0812041021h18a5889i270ed99712bca3ee@mail.gmail.com> <625b74080812041052o4d9ca963y3d16d577f72bf569@mail.gmail.com> Message-ID: <5959041b0812041259q4ae77945q80508add267aae83@mail.gmail.com> On Thu, Dec 4, 2008 at 12:52 PM, Dan Piponi wrote: > On Thu, Dec 4, 2008 at 10:21 AM, Matt Hellige wrote: >> \ f x y z -> f x z y == id ~> flip >> It's not clear to me whether your operad class can express this (or >> whether operads in general can express this) > > There exists an operad that can (at the cost of even more notation), > but you're right that the specific operad that I implemented can't. Makes sense. It turns out that with one more definition, we can express this fairly easily in my approach: infixr 2 ~*> (~*>) = (.) Now we can use functions that inspect multiple arguments, without moving our "position" in the argument list: f w x y z = concat $ map show [w,x,y,z] ex1 = (f $. id ~> flip ~*> id ~> id ~> length ~> id) 1 2 3 [4,5,6,7] roll f x y z = f y z x ex2 = (f $. id ~> roll ~*> id ~> id ~> length ~> id) 1 [4,5,6,7] 3 2 However, I have grave doubts about the usefulness of this, and I think it more than sacrifices whatever we gained in clarity. I maintain that ($.) and (~>) are clear and useful, but this seems to be one step too far... > Actually, if you look at the papers, mathematicians do have a > perfectly good notation for this, and it'd be cool if there were a > programming language that supported it well: drawing diagrams! Hear, hear! > Johannes Waldmann said: > >> Well, there is Combinatory Logic. > > But it's not known for its ease of use :-) And we'd also have to change the definitions of all of our functions. Ideally, we'd like the same definitions to work either way. Anyway, thanks for all your thoughts... Matt From andrewcoppin at btinternet.com Thu Dec 4 16:54:00 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Dec 4 16:47:15 2008 Subject: [Haskell-cafe] Animated line art Message-ID: <49385178.2040207@btinternet.com> So, the muse has taken me. I'm going to attempt to produce some animated mathematical drawings involving lines and curves. Gtk2hs has a Cairo binding that should make rendering the stuff fairly straight-forward. So no problems there. Now, what I *could* do is write a new Haskell program for each drawing I want, hard-coding in the necessary imperative loops for updating coordinates, looping over multiple lines, etc. But that wasn't be very Haskell, would it? ;-) It seems that the "correct" course of action is to design a DSL for declaratively describing animated line art. Does anybody have ideas about what such a thing might look like? From martijn at van.steenbergen.nl Thu Dec 4 16:58:55 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Dec 4 16:52:15 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <49385178.2040207@btinternet.com> References: <49385178.2040207@btinternet.com> Message-ID: <4938529F.5030708@van.steenbergen.nl> Andrew Coppin wrote: > It seems that the "correct" course of action is to design a DSL for > declaratively describing animated line art. Does anybody have ideas > about what such a thing might look like? You could take a look at Fran [1] and Yampa [2] which both seem to do animations in Haskell. [1] http://conal.net/Fran/ [2] http://www.haskell.org/yampa/ Martijn. From ganesh at earth.li Thu Dec 4 17:00:18 2008 From: ganesh at earth.li (Ganesh Sittampalam) Date: Thu Dec 4 16:53:35 2008 Subject: [Haskell-cafe] manipulating predicate formulae In-Reply-To: <92952f860812040344y2d15f74dsc6442943318f2808@mail.gmail.com> References: <92952f860812040344y2d15f74dsc6442943318f2808@mail.gmail.com> Message-ID: Hi, That sounds like it might be quite useful. What I'm doing is generating some predicates that involve addition/subtraction/comparison of integers and concatenation/comparison of lists of some abstract thing, and then trying to simplify them. An example would be simplifying \exists p_before . \exists p_after . \exists q_before . \exists q_after . \exists as . \exists bs . \exists cs . (length p_before == p_pos && length q_before == q_pos && (p_before == as && q_after == cs) && p_before ++ p_new ++ p_after == as ++ p_new ++ bs ++ q_old ++ cs && as ++ p_new ++ bs ++ q_old ++ cs == q_before ++ q_old ++ q_after) into q_pos - (p_pos + length p_new) >= 0 which uses some properties of length as well as some arithmetic. I don't expect this all to be done magically for me, but I'd like as much help as possible - at the moment I've been growing my own library of predicate transformations but it's all a bit ad-hoc. If I could look at your code I'd be very interested. Cheers, Ganesh On Thu, 4 Dec 2008, Immanuel Normann wrote: > Hi Ganesh, > > manipulating predicate formulae was a central part of my PhD research. I > implemented some normalization and standarcization functions in Haskell - > inspired by term rewriting (like normalization to Boolean ring > representation) as well as (as far as I know) novell ideas (standardization > of quantified formulae w.r.t associativity and commutativity). > If you are interested in that stuff I am pleased to provide you with more > information. May be you can describe in more detail what you are looking > for. > > Best, > Immanuel > > 2008/11/30 Ganesh Sittampalam > >> Hi, >> >> Are there any Haskell libraries around for manipulating predicate formulae? >> I had a look on hackage but couldn't spot anything. >> >> I am generating complex expressions that I'd like some programmatic help in >> simplifying. >> >> Cheers, >> >> Ganesh >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From dokondr at gmail.com Thu Dec 4 17:27:05 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Thu Dec 4 17:20:24 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? Message-ID: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> I am trying to define instance Show[MyType] so show (x:xs :: MyType) would return a single string where substrings corresponding to list elements will be separated by "\n". This would allow pretty printing of MyType list in several lines instead of one, as default Show does for lists. For example: data ShipInfo = Ship { name :: String, kind :: String, canons :: Int } deriving Show s1 = Ship {name ="HMS Fly", kind = "sloop", canons=16} s2 = Ship {name ="HMS Surprise", kind = "frigate", canons=42} -- Yet when I try to define: instance (Show ShipInfo) => Show [ShipInfo] where show (x:xs) = "<" ++ show x ++ ">" ++ show xs -- I get this error: Illegal instance declaration for `Show [ShipInfo]' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Show [ShipInfo]' Failed, modules loaded: none. -- On the other hand this definition: instance (Show a) => Show [a] where show (x:xs) = "<" ++ show x ++ ">" ++ show xs -- Gives a different error: Duplicate instance declarations: instance (Show a) => Show [a] -- Defined at C:/wks/haskell-wks/ShowMatrix.hs:37:0 instance (Show a) => Show [a] -- Defined in GHC.Show Failed, modules loaded: none. -- Note the last error implicitly tells us that defining Show [a] is possible in principle! -- In fact it already defined in GHC.Show !!! -- How to define Show [MyType] ? Thanks! Dmitri -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081205/8095778c/attachment.htm From martijn at van.steenbergen.nl Thu Dec 4 17:29:52 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Dec 4 17:23:10 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> Message-ID: <493859E0.1030702@van.steenbergen.nl> Dmitri O.Kondratiev wrote: > -- How to define Show [MyType] ? Define instance Show MyType and implement not only show (for 1 value of MyType) but also showList, which Show provides as well. You can do all the magic in there. HTH, Martijn. From jonathanccast at fastmail.fm Thu Dec 4 17:35:09 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Dec 4 17:28:22 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> Message-ID: <1228430109.13197.20.camel@jcchost> On Fri, 2008-12-05 at 01:27 +0300, Dmitri O.Kondratiev wrote: > I am trying to define instance Show[MyType] so > show (x:xs :: MyType) would return a single string where substrings > corresponding to list elements will be separated by "\n". > This would allow pretty printing of MyType list in several lines > instead of one, as default Show does for lists. > > For example: > > data ShipInfo = Ship { > name :: String, > kind :: String, > canons :: Int > } deriving Show > > s1 = Ship {name ="HMS Fly", kind = "sloop", canons=16} > s2 = Ship {name ="HMS Surprise", kind = "frigate", canons=42} > > -- Yet when I try to define: > instance (Show ShipInfo) => Show [ShipInfo] where > show (x:xs) = "<" ++ show x ++ ">" ++ show xs The context on this is borked: you already know Show ShipInfo, so you don't need to assume it here. > -- I get this error: > Illegal instance declaration for `Show [ShipInfo]' > (The instance type must be of form (T a b c) > where T is not a synonym, and a,b,c are distinct type > variables) Read this error again. Your instance is for the type `[] ShipInfo', which does not have the form GHC listed for you. The instance in GHC.Show (don't import it from there! Import it from Prelude, instead) is for a type of the form `[] a', which does have that form. Now, in this case, you don't need to define Show ([ShipInfo]), because the instance for Show [a] already does what you want; you just need to define an explicit instance for Show ShipInfo and over-ride the showList method. If you really, really wanted to define Show [ShipInfo], then putting {-# LANGUAGE FlexibleInstances, OverlappingInstances #-} at the beginning of your file would work. At the cost of using overlapping instances, of course. jcc From ryani.spam at gmail.com Thu Dec 4 17:46:24 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 4 17:39:42 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <1228430109.13197.20.camel@jcchost> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <1228430109.13197.20.camel@jcchost> Message-ID: <2f9b2d30812041446v7300700cx33c720745ed3943d@mail.gmail.com> > If you really, really wanted to define Show [ShipInfo], then putting > > {-# LANGUAGE FlexibleInstances, OverlappingInstances #-} > > at the beginning of your file would work. At the cost of using > overlapping instances, of course. And at the cost of causing code like this: > f :: Show a => [a] -> String > f xs = show xs to fail to compile (see "Incoherent Instances"). Implement "showList"; it's the Right Answer for this case. From jonathanccast at fastmail.fm Thu Dec 4 17:49:40 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Dec 4 17:42:52 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <2f9b2d30812041446v7300700cx33c720745ed3943d@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <1228430109.13197.20.camel@jcchost> <2f9b2d30812041446v7300700cx33c720745ed3943d@mail.gmail.com> Message-ID: <1228430980.13197.22.camel@jcchost> On Thu, 2008-12-04 at 14:46 -0800, Ryan Ingram wrote: > > If you really, really wanted to define Show [ShipInfo], then putting > > > > {-# LANGUAGE FlexibleInstances, OverlappingInstances #-} > > > > at the beginning of your file would work. At the cost of using > > overlapping instances, of course. > > And at the cost of causing code like this: > > > f :: Show a => [a] -> String > > f xs = show xs > > to fail to compile (see "Incoherent Instances"). Right. > Implement "showList"; it's the Right Answer for this case. Yeah. jcc From nicolas.frisby at gmail.com Thu Dec 4 18:09:34 2008 From: nicolas.frisby at gmail.com (Nicolas Frisby) Date: Thu Dec 4 18:02:53 2008 Subject: [Haskell-cafe] two type-level programming questions Message-ID: <5ce89fb50812041509l46ff2c8dl3226c4be9cbb0294@mail.gmail.com> 1) Type families, associated types, synonyms... can anything replace the use of TypeCast for explicit instance selection? Section 2, bullet 4 of http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap indicates a negative response. Any other ideas? 2) Any progress/options for kind polymorphism in instances? Thanks for your time. From ryani.spam at gmail.com Thu Dec 4 18:31:38 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 4 18:24:56 2008 Subject: [Haskell-cafe] two type-level programming questions In-Reply-To: <5ce89fb50812041509l46ff2c8dl3226c4be9cbb0294@mail.gmail.com> References: <5ce89fb50812041509l46ff2c8dl3226c4be9cbb0294@mail.gmail.com> Message-ID: <2f9b2d30812041531x3c2ebdib20f12a49c1d61bc@mail.gmail.com> Sort of. I believe you can use type equality constraints to replace the use of TypeCast; that is, in any code that looks like: > instance TypeCast a HTrue => ... you can write > instance (a ~ HTrue) => ... (at least, it has worked for me that way) This at least makes me feel a bit more monadic (warm & fuzzy!) than the indecipherable magic that is the declaration of TypeCast/TypeCast'/TypeCast'' -- ryan On Thu, Dec 4, 2008 at 3:09 PM, Nicolas Frisby wrote: > 1) Type families, associated types, synonyms... can anything replace > the use of TypeCast for explicit instance selection? Section 2, bullet > 4 of http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap indicates > a negative response. Any other ideas? > > 2) Any progress/options for kind polymorphism in instances? > > Thanks for your time. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From timd at macquarie.com.au Thu Dec 4 18:34:25 2008 From: timd at macquarie.com.au (Tim Docker) Date: Thu Dec 4 18:27:45 2008 Subject: [Haskell-cafe] detecting socket closure in haskell Message-ID: <9A015D433594EA478964C5B34AF3179B027987B3@ntsydexm06.pc.internal.macquarie.com> This is a haskell + networking question... I have a multi threaded haskell server, which accepts client connections, processes their requests, and returns results. It currently works as desired, except where a client drops a connection whilst the server is processing a request. In this circumstance, the server currently doesn't notice that the client has gone until it finishes the processing and attempt to read the next request. I'd like to change it so that the request is aborted as soon as the client disconnects. One way of doing this would would be to maintain a separate thread that is always reading from the client, and buffers until the main thread needs the information. Whilst this would detect the remote close, it also would potentially consume large amounts of memory to maintain this buffer. Hence I seem to need a means of detecting that a socket has been closed remotely, without actually reading from it. . Does anyone know how to do this? One reference I've found is this: http://stefan.buettcher.org/cs/conn_closed.html Apparently recv() with appropriate flags can detect this - though I'm not convinced that the code as shown on that page doesn't busy wait when there is unread data from the client. Any tips or pointers? Perhaps what I'm trying to do is not currently possible in haskell, without using the FFI (which would be ok). Or perhaps it's not possible in linux at all. Thanks, Tim From timd at macquarie.com.au Thu Dec 4 18:46:22 2008 From: timd at macquarie.com.au (Tim Docker) Date: Thu Dec 4 18:39:42 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <49385178.2040207@btinternet.com> References: <49385178.2040207@btinternet.com> Message-ID: <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> > It seems that the "correct" course of action is to design a DSL for declaratively describing animated line art. Does anybody have ideas about what such a thing might look like? Someone else already mentioned FRAN and it's ilk. But perhaps you don't need something that fancy. If you implement your drawing logic as a function from time to the appropriate render actions, ie | import qualified Graphics.Rendering.Cairo as C | | type Animation = Time -> C.Render () then you just need to call this function multiple times to generate sucessive frames. Tim From jason.dusek at gmail.com Thu Dec 4 18:53:05 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Dec 4 18:46:22 2008 Subject: [Haskell-cafe] class method name scope Message-ID: <42784f260812041553v362decc1ja285d9b2e407f952@mail.gmail.com> What proposals are out there to address the issue of scoping class methods? I always feel I must be careful, when exposing a class definition that I want clients to be able to extend, that I mustn't step on the namespace with semantically appropriate but overly general names (e.g. 'run'). It'd be nice if class method names were module scoped and could be qualified. -- _jsn From martijn at van.steenbergen.nl Thu Dec 4 18:54:41 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Dec 4 18:47:58 2008 Subject: [Haskell-cafe] detecting socket closure in haskell In-Reply-To: <9A015D433594EA478964C5B34AF3179B027987B3@ntsydexm06.pc.internal.macquarie.com> References: <9A015D433594EA478964C5B34AF3179B027987B3@ntsydexm06.pc.internal.macquarie.com> Message-ID: <49386DC1.3000404@van.steenbergen.nl> Tim Docker wrote: > One way of doing this would would be to maintain a separate thread that > is always reading from the client, and buffers until the main thread > needs the information. Whilst this would detect the remote close, it > also would potentially consume large amounts of memory to maintain this > buffer. I think flushing a lost connection causes an error. So instead of buffering its incoming data, you could try flushing the handle and see if that causes an error, which you can then catch. No idea if that will work, but it's worth a try. Martijn. From lrpalmer at gmail.com Thu Dec 4 19:14:45 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Dec 4 19:08:02 2008 Subject: [Haskell-cafe] class method name scope In-Reply-To: <42784f260812041553v362decc1ja285d9b2e407f952@mail.gmail.com> References: <42784f260812041553v362decc1ja285d9b2e407f952@mail.gmail.com> Message-ID: <7ca3f0160812041614t18ff8dccr157d3e0cc89c135a@mail.gmail.com> I have never run into such an issue. Typically classes tend to have the smallest possible basis of methods. I would consider a class with more than about 10 or 15 methods (including superclasses' methods) to indicate poor design. That is just a rough heuristic. But you're right, it would be nice if name qualification applied to classes as well, so that we wouldn't have to worry about it at all. On Thu, Dec 4, 2008 at 4:53 PM, Jason Dusek wrote: > What proposals are out there to address the issue of scoping > class methods? I always feel I must be careful, when exposing > a class definition that I want clients to be able to extend, > that I mustn't step on the namespace with semantically > appropriate but overly general names (e.g. 'run'). It'd be > nice if class method names were module scoped and could be > qualified. > > -- > _jsn > _______________________________________________ > 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/20081204/5959502b/attachment.htm From jason.dusek at gmail.com Thu Dec 4 19:43:01 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Dec 4 19:36:18 2008 Subject: [Haskell-cafe] class method name scope In-Reply-To: <7ca3f0160812041614t18ff8dccr157d3e0cc89c135a@mail.gmail.com> References: <42784f260812041553v362decc1ja285d9b2e407f952@mail.gmail.com> <7ca3f0160812041614t18ff8dccr157d3e0cc89c135a@mail.gmail.com> Message-ID: <42784f260812041643n554b83f2h3d6ec1ea7cc8844a@mail.gmail.com> It's not that I like to have a lot of methods in a class, but rather a lot of classes. -- _jsn From westondan at imageworks.com Thu Dec 4 19:49:59 2008 From: westondan at imageworks.com (Dan Weston) Date: Thu Dec 4 19:43:21 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> References: <49385178.2040207@btinternet.com> <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> Message-ID: <49387AB7.8060308@imageworks.com> Andrew, I can think of several reasons why simple time-indexed animation may be a bad idea. Some important aspects of animation are usually: 1) A main use case is playback, where time change is continuous and monotonic. 2) Differential action is often much cheaper than time jumping (i.e. between adjacent time steps most lines do not move and do not need to be recomputed. It is cheaper to modify the previous animation.) 3) Time is a topological space, with lots of nice properties: change of time is a group, intervals are decomposable, etc. Animation inherits this structure as a G-torsor (e.g. between two close enough times the line art should look very similar, there is no canonical start time). You are throwing this all away if you just treat line art like a point set. 4) Although your Time set may be discrete, you may want to pretend it is smooth to facilitate e.g. motion blur and simulation, which strongly favor a differential approach. There is often a need for run-up or adaptive time interval subdivision. Clip start and stop times are often changed interactively. Instead of defining a calculus (line art indexed by time), you may want to define an algebra (action of time change on line art). You can manipulate the algebra independently for efficiency (e.g. combine adjacent time intervals into one big interval if pointwise evaluation is cheap, or subdivide an interval if differential change is cheap) and then apply the final result to line art defined at some time origin. Take a quick read of http://en.wikipedia.org/wiki/Principal_bundle where the (group) G is time change and the (fiber bundle) P is the line art. At minimum, implement your time argument as a start time + delta time, and consider a State monad (or StateT monad transformer) to hold future optimizations like cached (time,art) pairs in case you change your mind. Dan Tim Docker wrote: >> It seems that the "correct" course of action is to design a DSL for > declaratively describing animated line art. Does anybody have ideas > about what such a thing might look like? > > Someone else already mentioned FRAN and it's ilk. But perhaps you don't > need something that fancy. If you implement your drawing logic as a > function from time to the appropriate render actions, ie > > | import qualified Graphics.Rendering.Cairo as C > | > | type Animation = Time -> C.Render () > > then you just need to call this function multiple times to generate > sucessive frames. > > Tim > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lrpalmer at gmail.com Thu Dec 4 19:50:34 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Dec 4 19:43:53 2008 Subject: [Haskell-cafe] class method name scope In-Reply-To: <42784f260812041643n554b83f2h3d6ec1ea7cc8844a@mail.gmail.com> References: <42784f260812041553v362decc1ja285d9b2e407f952@mail.gmail.com> <7ca3f0160812041614t18ff8dccr157d3e0cc89c135a@mail.gmail.com> <42784f260812041643n554b83f2h3d6ec1ea7cc8844a@mail.gmail.com> Message-ID: <7ca3f0160812041650k4da0a328n2530301a29367d90@mail.gmail.com> No deep inheritance? Then what's the problem? module X where class Foo a where foo :: a -> String module Y where class Foo' a where foo :: a -> String module Main where import qualified X import qualified Y instance X.Foo Int where foo _ = "X" instance Y.Foo' Int where foo _ = "Y" It is known that the first foo is referring to X.foo, and the second is referring to Y.foo. In fact... come to think of it, there are actually no namespace problems. The instance syntax is just a little quirky, since you don't qualify the LHS, even if the name is only imported qualified. Or is that not what you're referring to? Luke On Thu, Dec 4, 2008 at 5:43 PM, Jason Dusek wrote: > It's not that I like to have a lot of methods in a class, but > rather a lot of classes. > > -- > _jsn > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081204/9dbe0a1c/attachment.htm From donn at avvanta.com Thu Dec 4 20:15:01 2008 From: donn at avvanta.com (Donn Cave) Date: Thu Dec 4 20:08:19 2008 Subject: [Haskell-cafe] detecting socket closure in haskell Message-ID: <20081205011501.7C58893C4B@mail.avvanta.com> Quoth "Tim Docker" : | Hence I seem to need a means of detecting that a socket has been closed | remotely, without actually reading from it. . Does anyone know how to do | this? One reference I've found is this: | | http://stefan.buettcher.org/cs/conn_closed.html | | Apparently recv() with appropriate flags can detect this - though I'm | not convinced that the code as shown on that page doesn't busy wait when | there is unread data from the client. Right - poll() will still find data there, after the "peek", so you'll be running that loop as fast as you can make the 2 system calls, and what I think might be worse, it should keep reading the same 32 bytes at the head of the buffer ... and never notice the connection close. Well, I haven't tried it, but this solution doesn't make sense to me. | Any tips or pointers? Perhaps what I'm trying to do is not currently | possible in haskell, without using the FFI (which would be ok). Or | perhaps it's not possible in linux at all. I don't know of a way to do it in C. I think it's very likely that the kernel finds out only after all the data has been delivered through the network interface, so by the time you can even in principle know that the connection closed, all the data will either have been processed by the client or reside in memory somewhere on the computer. I guess you might try your buffering thread, and if you're really worried about undue amounts of buffered data, set some maximum size, where you either stop trying to notice end-of-file, or switch to another storage medium (e.g., disk file.) Donn From jason.dusek at gmail.com Thu Dec 4 20:48:25 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Dec 4 20:41:40 2008 Subject: [Haskell-cafe] class method name scope In-Reply-To: <7ca3f0160812041650k4da0a328n2530301a29367d90@mail.gmail.com> References: <42784f260812041553v362decc1ja285d9b2e407f952@mail.gmail.com> <7ca3f0160812041614t18ff8dccr157d3e0cc89c135a@mail.gmail.com> <42784f260812041643n554b83f2h3d6ec1ea7cc8844a@mail.gmail.com> <7ca3f0160812041650k4da0a328n2530301a29367d90@mail.gmail.com> Message-ID: <42784f260812041748o1ae8951dx1b4e9347746a9099@mail.gmail.com> Oh! Then there is no problem, after all. -- _jsn From immanuel.normann at googlemail.com Thu Dec 4 20:49:35 2008 From: immanuel.normann at googlemail.com (Immanuel Normann) Date: Thu Dec 4 20:42:53 2008 Subject: [Haskell-cafe] manipulating predicate formulae In-Reply-To: References: <92952f860812040344y2d15f74dsc6442943318f2808@mail.gmail.com> Message-ID: <92952f860812041749o7f35956fq9ee76f54fef46084@mail.gmail.com> Hi, you can browse my code here.It has become part of Hets the Heterogeneous Tool Set which is a parsing, static analysis and proof management tool combining various tools for different specification languages. However, let me warn you: the code isn't yet well documented at parts also ad hoc. Don't know whether it can help to solve your tasks. The goal of my normalization code is to bring formulae via equivalence transformations and alpha-renaming into a standard or normal form such that for instance the following three formulae become syntactically identical (i.e. not just modulo alpha equivalence or modulo associativity and commutativity): \begin{enumeratenumeric} \item $\forall \varepsilon . \varepsilon > 0 \Rightarrow \exists \delta . \forall x. \forall y. 0 < |x - y| \wedge |x - y| < \delta \Rightarrow | f (x) - f (y) | < \varepsilon$ \item $\forall \varepsilon . \exists \delta . \forall x, y. \varepsilon > 0 \Rightarrow (0 < |x - y| \wedge |x - y| < \delta \Rightarrow | f (x) - f (y) | < \varepsilon)$ \item $\forall e . \exists d . \forall a,b. e > 0 \wedge |a - b| < d \wedge 0 < |a - b| \Rightarrow | f (a) - f (b) | < e$ \end{enumeratenumeric} Cheers, Immanuel 2008/12/4 Ganesh Sittampalam > Hi, > > That sounds like it might be quite useful. What I'm doing is generating > some predicates that involve addition/subtraction/comparison of integers and > concatenation/comparison of lists of some abstract thing, and then trying to > simplify them. An example would be simplifying > > \exists p_before . \exists p_after . \exists q_before . \exists q_after . > \exists as . \exists bs . \exists cs . (length p_before == p_pos && length > q_before == q_pos && (p_before == as && q_after == cs) && p_before ++ p_new > ++ p_after == as ++ p_new ++ bs ++ q_old ++ cs && as ++ p_new ++ bs ++ q_old > ++ cs == q_before ++ q_old ++ q_after) > > into > > q_pos - (p_pos + length p_new) >= 0 > > which uses some properties of length as well as some arithmetic. I don't > expect this all to be done magically for me, but I'd like as much help as > possible - at the moment I've been growing my own library of predicate > transformations but it's all a bit ad-hoc. > > If I could look at your code I'd be very interested. > > Cheers, > > Ganesh > > > On Thu, 4 Dec 2008, Immanuel Normann wrote: > > Hi Ganesh, >> >> manipulating predicate formulae was a central part of my PhD research. I >> implemented some normalization and standarcization functions in Haskell - >> inspired by term rewriting (like normalization to Boolean ring >> representation) as well as (as far as I know) novell ideas >> (standardization >> of quantified formulae w.r.t associativity and commutativity). >> If you are interested in that stuff I am pleased to provide you with more >> information. May be you can describe in more detail what you are looking >> for. >> >> Best, >> Immanuel >> >> 2008/11/30 Ganesh Sittampalam >> >> Hi, >>> >>> Are there any Haskell libraries around for manipulating predicate >>> formulae? >>> I had a look on hackage but couldn't spot anything. >>> >>> I am generating complex expressions that I'd like some programmatic help >>> in >>> simplifying. >>> >>> Cheers, >>> >>> Ganesh >>> _______________________________________________ >>> 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/20081205/d1821401/attachment.htm From Ben.Lippmeier at anu.edu.au Thu Dec 4 21:19:31 2008 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Thu Dec 4 21:12:53 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> References: <49385178.2040207@btinternet.com> <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> Message-ID: <7BC4BD5C-51C5-4234-8FFE-4BA330EF0F0A@anu.edu.au> On 05/12/2008, at 10:46 AM, Tim Docker wrote: > Someone else already mentioned FRAN and it's ilk. But perhaps you > don't > need something that fancy. If you implement your drawing logic as a > function from time to the appropriate render actions, ie > > | import qualified Graphics.Rendering.Cairo as C > | > | type Animation = Time -> C.Render () > > then you just need to call this function multiple times to generate > sucessive frames. The ANUPlot graphics library I wrote does exactly this. The darcs repo is at http://code.haskell.org/ANUPlot/ANUPlot-HEAD/ It comes with lots of examples that do the sort of things you describe. Ben. From jason.dusek at gmail.com Thu Dec 4 22:04:37 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Dec 4 21:57:55 2008 Subject: [Haskell-cafe] two type-level programming questions In-Reply-To: <2f9b2d30812041531x3c2ebdib20f12a49c1d61bc@mail.gmail.com> References: <5ce89fb50812041509l46ff2c8dl3226c4be9cbb0294@mail.gmail.com> <2f9b2d30812041531x3c2ebdib20f12a49c1d61bc@mail.gmail.com> Message-ID: <42784f260812041904h12b79543l93ec03349fa5af6f@mail.gmail.com> More monadic? -- _jsn From pasalic at cs.rice.edu Thu Dec 4 22:18:29 2008 From: pasalic at cs.rice.edu (Emir Pasalic) Date: Thu Dec 4 22:11:56 2008 Subject: [Haskell-cafe] Finall Call For Papers (DSL WC) Message-ID: *** IFIP Working Conference on Domain Specific Languages (DSL WC) *** July 15-17, 2009, Oxford http://www.hope.cs.rice.edu/twiki/bin/view/WG211/DSLWC * Call for Papers Domain-specific languages are emerging as a fundamental component of software engineering practice. DSLs are often introduced when new domains such as web-scripting or markup come into existence, but it is also common to see DSLs being introduced and adopted for traditional domains such as parsing and data description. Developing software using DSLs has many benefits. DSLs are often designed based on existing notations that are already in use by experts in a given domain. As such, successful DSLs often reduce or eliminate the effort needed to transform the concept or innovation produced by the domain expert into an executable artifact or even a deliverable software product. DSL implementations can capture and mechanize a significant portion of the repetitive and mechanical tasks that a domain expert traditionally needed to perform in order to produce an executable. DSLs can in many cases capture and make widely available special expertise that only top specialists in a given domain might have. By capturing expert knowledge and reducing repetitive tasks, DSLs often also lead to software that is significantly more portable, more reliable and more understandable than it would otherwise be. DSLs can be viewed as having a dual role to general-purpose languages: whereas general purpose languages try to do everything as well as possible, DSLs are designed to find a domain where they can solve some class of problems -- no matter how small -- in the best possible way. Widely known examples of DSLs include Matlab, Verilog, SQL, LINQ, JavaScript, PERL, HTML, Open GL, Tcl/Tk, Macromedia Director, Mathematica/Maple, AutoLisp/AutoCAD, XSLT, RPM, Make, lex/yacc, LaTeX, PostScript, Excel, among many others. But while these tools have been widely successful, they still fall short of realizing the full idea behind them. The goal of this conference is to explore the extent to which incorporating modern principles of language design and software engineering can benefit existing and future domain-specific languages. The ultimate goal of using DSLs is to improve programmer productivity and software quality. Often, this is achieved by reducing the cost of initial software development as well as maintenance costs. These improvements - programs being easier to write and maintain - materialize as a result of domain-specific guarantees, analyses, testing techniques, verification techniques, and optimizations. * Paper Criteria Papers are sought addressing the research problems, fundamental principles, and practical techniques of DSLs, including but not limited to: - Foundations, including semantics, formal methods, type theory, and complexity theory - Language design, ranging from concrete syntax to semantic and typing issues - Software engineering, including domain analysis, software design, and round-trip engineering - Software processes, including metrics for software and language evaluation - Implementation techniques, including parsing, compiling, and program generation - Program analysis and automated transformation - Reverse engineering, re-engineering, design discovery, automated refactoring - Hardware/software codesign - Programming environments, including visual languages, debuggers, and testing infrastructure - Teaching DSLs and the use of DSLs in teaching Case studies, including engineering, bioinformatics, hardware specification languages, parallel computing languages, real-time and embedded systems, and networked and distributed domains Papers will be judged on the depth of their insight and the extent to which they translate specific experience into general lessons for domain-specific language designers and implementers, and software engineers. Papers can range from the practical to the theoretical; where appropriate, they should refer to actual languages, tools, and techniques, provide pointers to full definitions and implementations, and include empirical data on results. * Important Dates - July 23rd, 2008: First Call for Papers - November 12th, 2008: Final Call for Papers - December 14th, 2008: Abstract submission due. - December 21st, 2008: Paper submission deadline. - February 23rd, 2009: Author notification of decisions - March 22nd, 2009: Camera ready manuscripts due * Instructions for Authors Proceedings will be published in the Springer LNCS series. Submissions and final manuscripts are to follow the LNCS stylesheet formatting guidelines, and are not to exceed 25 pages. Please submit your manuscripts online using the EasyChair conference management system. * Program Committee Jon Bentley, Avayalabs Martin Erwig, Oregon State University Jeff Gray, University of Alabama at Birmingham Robert Grimm, New York University Jim Grundy, Intel Strategic CAD Labs Tom Henzinger, EPFL Sam Kamin, UIUC Dick Kieburtz, Portland State University Ralf L?mmel, University of Koblenz Julia Lawall, University of Copenhagen Benjamin Pierce, University of Pennsylvania Vivek Sarkar, Rice University Jeremy Siek, University of Colorado at Boulder Jos? Nuno Oliveira, University of Minho Doaitse Swierstra, Utrecht University Walid Taha (Chair), Rice University Eelco Visser, Delft University William Waite, University of Colorado at Boulder Stephanie Weirich, University of Pennsylvania * Organizers General Chair: Jeremy Gibbons, Oxford University Publicity Chair: Emir Pasalic, LogicBlox -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081204/b3fedd92/attachment.htm From nicolas.frisby at gmail.com Thu Dec 4 22:38:03 2008 From: nicolas.frisby at gmail.com (Nicolas Frisby) Date: Thu Dec 4 22:31:20 2008 Subject: [Haskell-cafe] Could FDs help usurp an ATs syntactic restriction? Message-ID: <5ce89fb50812041938s1df748e7vdaead568b53fce9d@mail.gmail.com> >From the error below, I'm inferring that the RHS of the associated type definition can only contain type variables from the instance head, not the instance context. I didn't explicitly see this restriction when reading the GHC/Type_families entry. Could perhaps the "a b -> bn" functional dependency of the TypeEq class lift this restriction for bn? This isn't my ball park, but that idea has my hopes up :). {-# LANGUAGE TypeFamilies #-} import TypeEq -- Attempting to encapsulate TypeEq behind an associated type. class EQ a b where type BN a b instance TypeEq a b bn => EQ a b where type BN a b = bn results in an error /tmp/Test.hs:9:16: Not in scope: type variable `bn' Failed, modules loaded: none. From magicloud.magiclouds at gmail.com Thu Dec 4 23:55:07 2008 From: magicloud.magiclouds at gmail.com (Magicloud) Date: Thu Dec 4 23:48:43 2008 Subject: [Haskell-cafe] Hat cannot use with ghc 6.10? Message-ID: <4938B42B.9010403@gmail.com> Hi, I want to do some tracing, and I thought hat could help. Well hmake and hat both could not been made with ghc 6.10.... From clawsie at fastmail.fm Thu Dec 4 23:58:46 2008 From: clawsie at fastmail.fm (brad clawsie) Date: Thu Dec 4 23:52:09 2008 Subject: [Haskell-cafe] propogation of Error Message-ID: <877i6fb4l5.fsf@arch.gateway.2wire.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi. i have a partial library for parsing ogg files here: http://hpaste.org/12705 i have a question about an aspect of the code. in the function checkHeader there are a sequence of functions to check various elements in the header of a ogg file. if i test this function against a file that *isn't* an ogg file, i.e. badFile = "/home/user/.bashrc" :: String main = parseOgg badFile >>= (\x -> print x) i would expect to get back the Error from the *first* function in the sequence of functions in checkHeader (oggHeaderError from the oggHeader function). but instead i always see the Error from the *last* function in the sequence, OggPacketFlagError from the OggPacketFlag function. why is this? is there any way i can get the desired behavior...i.e. see the Error from the first function in the sequence that fails? thanks brad -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkk4tQYACgkQxRg3RkRK91PD9gCePloWFIvE9WjcfApxR2RmnHQ0 pUgAn0WAzRQR/y2yE8yeYP1s7eKHyKDh =EcOM -----END PGP SIGNATURE----- From conrad at metadecks.org Fri Dec 5 00:41:31 2008 From: conrad at metadecks.org (Conrad Parker) Date: Fri Dec 5 00:34:47 2008 Subject: [Haskell-cafe] Fun with type functions In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C33281447D7F@EA-EXMSG-C334.europe.corp.microsoft.com> References: <638ABD0A29C8884A91BC5FB5C349B1C33281447D7F@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: 2008/11/27 Simon Peyton-Jones : > > can you tell us about the most persuasive, fun application > you've encountered, for type families or functional dependencies? Hi, I certainly had fun with the Instant Insanity puzzle, in Monad.Reader issue 8: http://www.haskell.org/haskellwiki/User:ConradParker/InstantInsanity That was using functional dependencies. Then Pepe Iborra pasted a version of Instant Insanity with type families: http://hpaste.org/2689 Looking back at this, Manuel left the following comment: -- There is unfortunately, no simple way to print the normalised type. -- In fact, GHC goes to great length to show types with as little -- normalisation as possible to users. (Especially for error messages, -- that usually makes them much easier to understand.) However, with -- type families, I think we really ought to have a ghci command to -- specifically request a normalised type. I'll put that on my -- TODO list! -- For the moment, you can of course try forcing normalisation by -- triggering type errors; eg -- > :t solution :: Int (Does ghci now have a command for printing normalised types?) There are also links to haskell-cafe discussion and some other implementations (in C++ templates and D) to, um, compare: http://www.haskell.org/haskellwiki/User_talk:ConradParker/InstantInsanity cheers, Conrad. From ganesh at earth.li Fri Dec 5 01:33:44 2008 From: ganesh at earth.li (Ganesh Sittampalam) Date: Fri Dec 5 01:27:00 2008 Subject: [Haskell-cafe] manipulating predicate formulae In-Reply-To: <92952f860812041749o7f35956fq9ee76f54fef46084@mail.gmail.com> References: <92952f860812040344y2d15f74dsc6442943318f2808@mail.gmail.com> <92952f860812041749o7f35956fq9ee76f54fef46084@mail.gmail.com> Message-ID: Thanks - I'll take a look. One pre-emptive question: if I want to use it, it'd be more convenient, though not insurmountable, if that code was BSD3-licenced, since it will fit in better with the licence for camp , which I might eventually want to integrate my code into. (the predicates I described are intended to be the commutation conditions for patches). Is that likely to be possible? Cheers, Ganesh On Fri, 5 Dec 2008, Immanuel Normann wrote: > Hi, > > you can browse my code > here.It > has become part of > Hets the Heterogeneous Tool Set which is a > parsing, static analysis and proof management tool combining various tools > for different specification languages. > However, let me warn you: the code isn't yet well documented at parts also > ad hoc. Don't know whether it can help to solve your tasks. > The goal of my normalization code is to bring formulae via equivalence > transformations and alpha-renaming into a standard or normal form such that > for instance the following three formulae become syntactically identical > (i.e. not just modulo alpha equivalence or modulo associativity and > commutativity): > > \begin{enumeratenumeric} > \item $\forall \varepsilon . \varepsilon > 0 \Rightarrow \exists \delta . > \forall x. \forall y. 0 < |x - y| \wedge |x - y| < \delta \Rightarrow | f > (x) - f (y) | < \varepsilon$ > > \item $\forall \varepsilon . \exists \delta . \forall x, y. \varepsilon > > 0 > \Rightarrow (0 < |x - y| \wedge |x - y| < \delta \Rightarrow | f (x) - f > (y) | < \varepsilon)$ > > \item $\forall e . \exists d . \forall a,b. e > 0 > \wedge |a - b| < d \wedge 0 < |a - b| \Rightarrow | f (a) - f (b) | < e$ > \end{enumeratenumeric} > > Cheers, > > Immanuel > > > > 2008/12/4 Ganesh Sittampalam > >> Hi, >> >> That sounds like it might be quite useful. What I'm doing is generating >> some predicates that involve addition/subtraction/comparison of integers and >> concatenation/comparison of lists of some abstract thing, and then trying to >> simplify them. An example would be simplifying >> >> \exists p_before . \exists p_after . \exists q_before . \exists q_after . >> \exists as . \exists bs . \exists cs . (length p_before == p_pos && length >> q_before == q_pos && (p_before == as && q_after == cs) && p_before ++ p_new >> ++ p_after == as ++ p_new ++ bs ++ q_old ++ cs && as ++ p_new ++ bs ++ q_old >> ++ cs == q_before ++ q_old ++ q_after) >> >> into >> >> q_pos - (p_pos + length p_new) >= 0 >> >> which uses some properties of length as well as some arithmetic. I don't >> expect this all to be done magically for me, but I'd like as much help as >> possible - at the moment I've been growing my own library of predicate >> transformations but it's all a bit ad-hoc. >> >> If I could look at your code I'd be very interested. >> >> Cheers, >> >> Ganesh >> >> >> On Thu, 4 Dec 2008, Immanuel Normann wrote: >> >> Hi Ganesh, >>> >>> manipulating predicate formulae was a central part of my PhD research. I >>> implemented some normalization and standarcization functions in Haskell - >>> inspired by term rewriting (like normalization to Boolean ring >>> representation) as well as (as far as I know) novell ideas >>> (standardization >>> of quantified formulae w.r.t associativity and commutativity). >>> If you are interested in that stuff I am pleased to provide you with more >>> information. May be you can describe in more detail what you are looking >>> for. >>> >>> Best, >>> Immanuel >>> >>> 2008/11/30 Ganesh Sittampalam >>> >>> Hi, >>>> >>>> Are there any Haskell libraries around for manipulating predicate >>>> formulae? >>>> I had a look on hackage but couldn't spot anything. >>>> >>>> I am generating complex expressions that I'd like some programmatic help >>>> in >>>> simplifying. >>>> >>>> Cheers, >>>> >>>> Ganesh >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>>> >>> > From ryani.spam at gmail.com Fri Dec 5 02:01:53 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Dec 5 01:55:10 2008 Subject: [Haskell-cafe] two type-level programming questions In-Reply-To: <42784f260812041904h12b79543l93ec03349fa5af6f@mail.gmail.com> References: <5ce89fb50812041509l46ff2c8dl3226c4be9cbb0294@mail.gmail.com> <2f9b2d30812041531x3c2ebdib20f12a49c1d61bc@mail.gmail.com> <42784f260812041904h12b79543l93ec03349fa5af6f@mail.gmail.com> Message-ID: <2f9b2d30812042301v2fda6ab9he5b91e031b445bcd@mail.gmail.com> See slide 40 of "Weaing the Hair Shirt: A Retrospective on Haskell", Simon Peyton-Jones, POPL 2003 http://research.microsoft.com/Users/simonpj/papers/haskell-retrospective/index.htm -- ryan On Thu, Dec 4, 2008 at 7:04 PM, Jason Dusek wrote: > More monadic? > > -- > _jsn > From sebf at informatik.uni-kiel.de Fri Dec 5 05:17:24 2008 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Fri Dec 5 05:11:12 2008 Subject: [Haskell-cafe] FunDeps vs. Associated Types Message-ID: <618594BE-B4BF-4A90-9159-9F2268E23C68@informatik.uni-kiel.de> Dear Haskellers, I have a question regarding the correspondence between functional dependencies and associated types. > {-# LANGUAGE TypeFamilies, > FlexibleInstances, > MultiParamTypeClasses, > FunctionalDependencies > #-} With associated types, we can define a (useless[^1]) type class > class Useless a > where > type T a > useless :: a -> T a and instances > instance Useless () > where > type T () = () > useless = id > > instance Useless a => Useless (() -> a) > where > type T (() -> a) = T a > useless f = useless (f ()) Now we can compute `()` in many different ways: useless () useless (\()->()) ... I thought I could express the same with a multi-parameter type class and a functional dependency: > class UselessFD a b | a -> b > where > uselessFD :: a -> b But the corresponding instances > instance UselessFD () () > where > uselessFD = id > > instance UselessFD a b => UselessFD (() -> a) b > where > uselessFD f = uselessFD (f ()) are not accepted (at least by ghc-6.10.1) without allowing undecidable instances: useless.lhs:50:2: Illegal instance declaration for `UselessFD (() -> a) b' (the Coverage Condition fails for one of the functional dependencies; Use -XUndecidableInstances to permit this) In the instance declaration for `UselessFD (() -> a) b' Is there a simple explanation for this? Cheers, Sebastian [^1]: Originally, I was implementing hidden generation of unique identifiers. So instead of `useless :: (() -> () -> ... -> ()) -> ()` I got something like `withUnique :: (ID -> ... -> ID -> a) -> a`. From Tom.Schrijvers at cs.kuleuven.be Fri Dec 5 05:36:11 2008 From: Tom.Schrijvers at cs.kuleuven.be (Tom Schrijvers) Date: Fri Dec 5 05:30:34 2008 Subject: [Haskell-cafe] FunDeps vs. Associated Types In-Reply-To: <618594BE-B4BF-4A90-9159-9F2268E23C68@informatik.uni-kiel.de> References: <618594BE-B4BF-4A90-9159-9F2268E23C68@informatik.uni-kiel.de> Message-ID: On Fri, 5 Dec 2008, Sebastian Fischer wrote: > Dear Haskellers, > > I have a question regarding the correspondence between functional > dependencies and associated types. > >> {-# LANGUAGE TypeFamilies, >> FlexibleInstances, >> MultiParamTypeClasses, >> FunctionalDependencies >> #-} > > With associated types, we can define a (useless[^1]) type class > >> class Useless a >> where >> type T a >> useless :: a -> T a > > and instances > >> instance Useless () >> where >> type T () = () >> useless = id >> >> instance Useless a => Useless (() -> a) >> where >> type T (() -> a) = T a >> useless f = useless (f ()) > > Now we can compute `()` in many different ways: > > useless () > useless (\()->()) > ... > > I thought I could express the same with a multi-parameter type class > and a functional dependency: > >> class UselessFD a b | a -> b >> where >> uselessFD :: a -> b > > But the corresponding instances > >> instance UselessFD () () >> where >> uselessFD = id >> >> instance UselessFD a b => UselessFD (() -> a) b >> where >> uselessFD f = uselessFD (f ()) > > are not accepted (at least by ghc-6.10.1) without allowing undecidable > instances: > > useless.lhs:50:2: > Illegal instance declaration for `UselessFD (() -> a) b' > (the Coverage Condition fails for one of the functional dependencies; > Use -XUndecidableInstances to permit this) > In the instance declaration for `UselessFD (() -> a) b' > > Is there a simple explanation for this? GHC does not implement the same conditions for type families and functional dependencies. Theoretically the same conditions may be used for both. The Coverage Condition is unnecessarily restrictive. A more relaxed condition has been proposed in the literature (JFP paper on using CHRs for FDs; our ICFP'08 paper), which GHC implements for type families but not functional dependencies. -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: tom.schrijvers@cs.kuleuven.be url: http://www.cs.kuleuven.be/~toms/ From jules at jellybean.co.uk Fri Dec 5 05:59:02 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Dec 5 05:52:20 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> Message-ID: <49390976.4030000@jellybean.co.uk> Dmitri O.Kondratiev wrote: > I am trying to define instance Show[MyType] so > show (x:xs :: MyType) would return a single string where substrings > corresponding to list elements will be separated by "\n". > This would allow pretty printing of MyType list in several lines instead > of one, as default Show does for lists. You're doing it wrong. Show is not for pretty-printing. Show is for the production of haskell syntax for debugging and copy-pasting into test cases, as well as for use with 'Read'. If you want to pretty print, use a different function name. Jules From dgorin at dc.uba.ar Fri Dec 5 07:52:39 2008 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Fri Dec 5 07:58:35 2008 Subject: [Haskell-cafe] propogation of Error In-Reply-To: <877i6fb4l5.fsf@arch.gateway.2wire.net> References: <877i6fb4l5.fsf@arch.gateway.2wire.net> Message-ID: <913F871A-C11B-41FD-87D8-F0F4A33D1A1B@dc.uba.ar> > i would expect to get back the Error from the *first* function in the > sequence of functions in checkHeader (oggHeaderError from the > oggHeader > function). but instead i always see the Error from the *last* function > in the sequence, OggPacketFlagError from the OggPacketFlag function. > why > is this? is there any way i can get the desired behavior...i.e. see > the > Error from the first function in the sequence that fails? Hi You are essentially asking why this function: checkHeader handle = ((oggHeader handle) >> (oggStreamFlag handle) >> (oggHeaderFlag handle) >> (skipBytes handle 20) >> (oggPageSecCount handle) >> (oggPacketFlag handle)) returns the last error (OggPacketFlagError) instead of the first one. Some type annotations might help you see what is going on. So let's ask ghci the type of, e.g. oggHeaderFlag *File.Ogg> :t oggHeaderFlag oggHeaderFlag :: SIO.Handle -> IO (Either OggParseErrorType [Char]) oggHeaderFlag takes a handle, and computes either an error or a string. But since you are using >>, the computed value is not passed to the next function in the pipe! There is no way checkHeader can stop early simply because it is ignoring the intermediate results altogether. Since you are importing Control.Monad.Error, I believe you would probably want oggHeaderFlag et al to have type: SIO.Handle -> ErrorT OggParseErrorType IO [Char] This will propagate errors correctly. You can see a version of your code using ErrorT here: http://hpaste.org/12705#a1 Daniel From gianfranco.alongi at gmail.com Fri Dec 5 08:35:20 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Fri Dec 5 08:28:36 2008 Subject: [Haskell-cafe] Quickcheck in industry - own experience. Message-ID: http://writert.blogspot.com/2008/12/quickchecking-code-i-c.html /Gf From wagner.andrew at gmail.com Fri Dec 5 07:40:38 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Fri Dec 5 09:10:20 2008 Subject: [Haskell-cafe] Functional version of this OO snippet Message-ID: Hi all, public interface IEngine { void foo(); void bar(string bah); ... } public class Program { public void Run(IEngine engine){ while(true){ string command = GetLine(); if (command.startsWith("foo")){ engine.foo(); } else if (command.startsWith("bar")){ engine.bar(command); ... else break; } In other words, I want to provide the same UI across multiple implementations of the engine that actually processes the commands. Thanks in advance. From tom.davie at gmail.com Fri Dec 5 09:24:52 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 09:18:10 2008 Subject: [Haskell-cafe] Functional version of this OO snippet In-Reply-To: References: Message-ID: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> On 5 Dec 2008, at 13:40, Andrew Wagner wrote: > Hi all, > public interface IEngine { > void foo(); > void bar(string bah); > ... > } > public class Program { > public void Run(IEngine engine){ > while(true){ > string command = GetLine(); > if (command.startsWith("foo")){ > engine.foo(); > } else if (command.startsWith("bar")){ > engine.bar(command); > ... > else break; > } > > In other words, I want to provide the same UI across multiple > implementations of the engine that actually processes the commands. class IEngine a where foo :: a -> String bar :: a -> String -> String run :: IEngine a => a -> IO () run x = interact (unlines . processCommand x . lines) processCommand e c | "foo" `isPrefixOf` c = foo e | "bar" `isPrefixOf` c = bar e c That should about do it. Bob From tom.davie at gmail.com Fri Dec 5 09:26:02 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 09:19:20 2008 Subject: [Haskell-cafe] Functional version of this OO snippet In-Reply-To: References: Message-ID: <3ADE0B04-7F55-440E-880F-65CB794572D6@gmail.com> > > In other words, I want to provide the same UI across multiple > implementations of the engine that actually processes the commands. You can ofc make my reply somewhat more functional by removing the interact from run, and just making it have type IEngine a => a -> String -> String. That way it will be nice and functional and composable and fit into a larger system. Bob From lemming at henning-thielemann.de Fri Dec 5 10:04:22 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Dec 5 09:57:38 2008 Subject: [Haskell-cafe] efficient combination of foldl' and foldr -> foldl'r Message-ID: I want to do a foldl' and a foldr in parallel on a list. I assumed it would be no good idea to run foldl' and foldr separately, because then the input list must be stored completely between the calls of foldl' and foldr. I wanted to be clever and implemented a routine which does foldl' and foldr in one go. But surprisingly, at least in GHCi, my clever routine is less efficient than the naive one. Is foldl'rNaive better than I expect, or is foldl'r worse than I hope? module FoldLR where import Data.List (foldl', ) import Control.Arrow (first, second, (***), ) foldl'r, foldl'rNaive :: (b -> a -> b) -> b -> (c -> d -> d) -> d -> [(a,c)] -> (b,d) foldl'r f b0 g d0 = first ($b0) . foldr (\(a,c) ~(k,d) -> (\b -> k $! f b a, g c d)) (id,d0) foldl'rNaive f b g d xs = (foldl' f b *** foldr g d) $ unzip xs test, testNaive :: (Integer, Char) test = second last $ foldl'r (+) 0 (:) "" $ replicate 1000000 (1,'a') {- *FoldLR> test (1000000,'a') (2.65 secs, 237509960 bytes) -} testNaive = second last $ foldl'rNaive (+) 0 (:) "" $ replicate 1000000 (1,'a') {- *FoldLR> testNaive (1000000,'a') (0.50 secs, 141034352 bytes) -} From apfelmus at quantentunnel.de Fri Dec 5 10:20:24 2008 From: apfelmus at quantentunnel.de (Apfelmus, Heinrich) Date: Fri Dec 5 10:13:47 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> Message-ID: Thomas Davie wrote: > Andrew Wagner wrote: > >> Hi all, >> public interface IEngine { >> void foo(); >> void bar(string bah); >> ... >> } >> public class Program { >> public void Run(IEngine engine){ >> while(true){ >> string command = GetLine(); >> if (command.startsWith("foo")){ >> engine.foo(); >> } else if (command.startsWith("bar")){ >> engine.bar(command); >> ... >> else break; >> } >> >> In other words, I want to provide the same UI across multiple >> implementations of the engine that actually processes the commands. > > class IEngine a where > foo :: a -> String > bar :: a -> String -> String You don't even need a type class, a simple data type is enough. data Engine = Engine { foo :: IO (), bar :: String -> IO () } run e = processCommand e =<< getLine processCommand e c | "foo" `isPrefixOf` c = foo e >> run e | "bar" `isPrefixOf` c = bar e c >> run e | otherwise = return () This always works because all object methods expect a "self" argument. In other words, all type class translations of OOP classes have the form class IFoo a where method1 :: a -> ... method2 :: a -> ... ... See also http://www.haskell.org/haskellwiki/Existential_type#Using_constructors_and_combinators Regards, H. Apfelmus From tom.davie at gmail.com Fri Dec 5 10:32:00 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 10:25:34 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> Message-ID: <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> > You don't even need a type class, a simple data type is enough. Very true, but I disagree that you've made it functional in any way, IO is all about sequencing things, it's very much not a functional style > > data Engine = Engine { foo :: IO (), bar :: String -> IO () } > > run e = processCommand e =<< getLine > > processCommand e c > | "foo" `isPrefixOf` c = foo e >> run e > | "bar" `isPrefixOf` c = bar e c >> run e > | otherwise = return () This is much nicer done as functions from String -> String, it becomes much more compassable, removes a sequential style from your code and stops processCommand depending on always working with the "run" function making it a bit more orthogonal. data Engine = Engine {foo :: String, bar :: String -> String} run e = unlines . map (proccesCommand e) . lines processCommand e c | "foo" `isPrefixOf` c = foo e | "bar" `isPrefixOf` c = bar e c | otherwise = "" Bob From martijn at van.steenbergen.nl Fri Dec 5 10:35:51 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Dec 5 10:29:05 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) Message-ID: <49394A57.50405@van.steenbergen.nl> Hello all, How do I implement the following? instance Applicative f => Applicative (StateT s f) The implementation of pure is trivial, but I can't figure out an implementation for <*>. Is it possible at all, or do I need to require f to be a monad? Thanks in advance, Martijn. From duncan.coutts at worc.ox.ac.uk Fri Dec 5 10:37:31 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Dec 5 10:30:51 2008 Subject: [Haskell-cafe] deleting spam on the wiki Message-ID: <1228491451.10115.277.camel@localhost> Who is able to delete wiki spam? http://haskell.org/haskellwiki/?title=Special:Contributions&target=Tomso123 All the pages created by this user appear to be spam (check the google translation) so the account should probably be deleted too. As I understand it, any registered user can revert changes to a page: http://www.haskell.org/haskellwiki/Help:Editing However if a registered user creates new spam pages then other ordinary registered users cannot revert that change. Is there some way of reporting spam pages to the appropriate people that I missed? Duncan From apfelmus at quantentunnel.de Fri Dec 5 10:42:54 2008 From: apfelmus at quantentunnel.de (Apfelmus, Heinrich) Date: Fri Dec 5 10:36:17 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> Message-ID: Thomas Davie wrote: >> You don't even need a type class, a simple data type is enough. > > Very true, but I disagree that you've made it functional in any way, IO > is all about sequencing things, it's very much not a functional style >> >> data Engine = Engine { foo :: IO (), bar :: String -> IO () } > > This is much nicer done as functions from String -> String Sure, I agree. I was just replicating foo and bar from the OP because I don't know what kind of effect he had in mind. I mean, instead of merely mapping each command in isolation, he could want to accumulate a value or read files or something. Regards, H. Apfelmus From tom.davie at gmail.com Fri Dec 5 10:50:28 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 10:43:45 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> Message-ID: <9E633387-15B8-4C49-ADC3-18F23FB3F9FD@gmail.com> On 5 Dec 2008, at 16:42, Apfelmus, Heinrich wrote: > Thomas Davie wrote: >>> You don't even need a type class, a simple data type is enough. >> >> Very true, but I disagree that you've made it functional in any >> way, IO >> is all about sequencing things, it's very much not a functional style >>> >>> data Engine = Engine { foo :: IO (), bar :: String -> IO () } >> >> This is much nicer done as functions from String -> String > > Sure, I agree. I was just replicating foo and bar from the OP > because I don't know what kind of effect he had in mind. I mean, > instead > of merely mapping each command in isolation, he could want to > accumulate > a value or read files or something. Sure, and he could then use a fold instead of a map. Reading files is problematic, but as long as you're only doing it once (the most common situation) is entirely fine wrapped up in an unsafePerformIO. Either way, the question was how to do it functionally, and to do it functionally, and with all of the nice shiny benefits we get with functional code like composibility and orthogonality, you need to do it with String -> String. Bob From ross at soi.city.ac.uk Fri Dec 5 10:54:03 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Dec 5 10:47:21 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: <49394A57.50405@van.steenbergen.nl> References: <49394A57.50405@van.steenbergen.nl> Message-ID: <20081205155359.GA3690@soi.city.ac.uk> On Fri, Dec 05, 2008 at 04:35:51PM +0100, Martijn van Steenbergen wrote: > How do I implement the following? > > instance Applicative f => Applicative (StateT s f) > > The implementation of pure is trivial, but I can't figure out an > implementation for <*>. Is it possible at all, or do I need to require f > to be a monad? Yes, because you need part of the value generated by the first computation, namely the state (inside the f), to construct the second one. You can do that in a Monad, but not in an Applicative. From tom.davie at gmail.com Fri Dec 5 10:59:04 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 10:52:19 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: <20081205155359.GA3690@soi.city.ac.uk> References: <49394A57.50405@van.steenbergen.nl> <20081205155359.GA3690@soi.city.ac.uk> Message-ID: On 5 Dec 2008, at 16:54, Ross Paterson wrote: > On Fri, Dec 05, 2008 at 04:35:51PM +0100, Martijn van Steenbergen > wrote: >> How do I implement the following? >> >> instance Applicative f => Applicative (StateT s f) >> >> The implementation of pure is trivial, but I can't figure out an >> implementation for <*>. Is it possible at all, or do I need to >> require f >> to be a monad? > > Yes, because you need part of the value generated by the first > computation, > namely the state (inside the f), to construct the second one. You > can do > that in a Monad, but not in an Applicative. I don't think that's true, although I'm yet to decide if Applicative for State is possible. someState <*> someOtherState should take the value out of the first state, take the value out of the second state, apply one to the other, and return a new stateful value as the result. At no point in that description do I make mention of the previous state of one of these values. Bob From duncan.coutts at worc.ox.ac.uk Fri Dec 5 11:00:42 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Dec 5 10:54:00 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: <9E633387-15B8-4C49-ADC3-18F23FB3F9FD@gmail.com> References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> <9E633387-15B8-4C49-ADC3-18F23FB3F9FD@gmail.com> Message-ID: <1228492842.10115.289.camel@localhost> On Fri, 2008-12-05 at 16:50 +0100, Thomas Davie wrote: > Sure, and he could then use a fold instead of a map. Reading files is > problematic, but as long as you're only doing it once (the most common > situation) is entirely fine wrapped up in an unsafePerformIO. Nooooo! Please don't go telling people it's entirely fine to use unsafePerformIO like that (or at all really). Duncan From tom.davie at gmail.com Fri Dec 5 11:06:55 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 11:00:14 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: <1228492842.10115.289.camel@localhost> References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> <9E633387-15B8-4C49-ADC3-18F23FB3F9FD@gmail.com> <1228492842.10115.289.camel@localhost> Message-ID: On 5 Dec 2008, at 17:00, Duncan Coutts wrote: > On Fri, 2008-12-05 at 16:50 +0100, Thomas Davie wrote: > >> Sure, and he could then use a fold instead of a map. Reading files >> is >> problematic, but as long as you're only doing it once (the most >> common >> situation) is entirely fine wrapped up in an unsafePerformIO. > > Nooooo! > > Please don't go telling people it's entirely fine to use > unsafePerformIO > like that (or at all really). Exactly what isn't fine about it? Bob From duncan.coutts at worc.ox.ac.uk Fri Dec 5 11:46:32 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Dec 5 11:40:08 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> <9E633387-15B8-4C49-ADC3-18F23FB3F9FD@gmail.com> <1228492842.10115.289.camel@localhost> Message-ID: <1228495592.10115.296.camel@localhost> On Fri, 2008-12-05 at 17:06 +0100, Thomas Davie wrote: > On 5 Dec 2008, at 17:00, Duncan Coutts wrote: > > > On Fri, 2008-12-05 at 16:50 +0100, Thomas Davie wrote: > > > >> Sure, and he could then use a fold instead of a map. Reading files > >> is > >> problematic, but as long as you're only doing it once (the most > >> common > >> situation) is entirely fine wrapped up in an unsafePerformIO. > > > > Nooooo! > > > > Please don't go telling people it's entirely fine to use > > unsafePerformIO > > like that (or at all really). > > Exactly what isn't fine about it? It's the antithesis of pure functional programming. It's so unsafe that we don't even have a semantics for it. One needs pretty special justification for using unsafePerformIO and such cases should be hidden in libraries presenting pure interfaces, not used willy-nilly in general application code. Note that I'm not claiming that it's necessarily going to do bad things in the specific case you're imagining using it in. However just because it happens not to do bad things in this case does not mean that it's ok to use it here or in general. Duncan From schlepptop at henning-thielemann.de Fri Dec 5 12:01:25 2008 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Fri Dec 5 11:50:13 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <49390976.4030000@jellybean.co.uk> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <49390976.4030000@jellybean.co.uk> Message-ID: <49395E65.6070206@henning-thielemann.de> Jules Bean schrieb: > Dmitri O.Kondratiev wrote: >> I am trying to define instance Show[MyType] so >> show (x:xs :: MyType) would return a single string where substrings >> corresponding to list elements will be separated by "\n". >> This would allow pretty printing of MyType list in several lines >> instead of one, as default Show does for lists. > > You're doing it wrong. > > Show is not for pretty-printing. (+1) > Show is for the production of haskell syntax for debugging and > copy-pasting into test cases, as well as for use with 'Read'. > > If you want to pretty print, use a different function name. Maybe related: http://www.haskell.org/haskellwiki/List_instance From ross at soi.city.ac.uk Fri Dec 5 12:18:52 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Dec 5 12:12:09 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: References: <49394A57.50405@van.steenbergen.nl> <20081205155359.GA3690@soi.city.ac.uk> Message-ID: <20081205171852.GA4619@soi.city.ac.uk> On Fri, Dec 05, 2008 at 04:59:04PM +0100, Thomas Davie wrote: > > On 5 Dec 2008, at 16:54, Ross Paterson wrote: > >> On Fri, Dec 05, 2008 at 04:35:51PM +0100, Martijn van Steenbergen >> wrote: >>> How do I implement the following? >>> >>> instance Applicative f => Applicative (StateT s f) >>> >>> The implementation of pure is trivial, but I can't figure out an >>> implementation for <*>. Is it possible at all, or do I need to >>> require f >>> to be a monad? >> >> Yes, because you need part of the value generated by the first >> computation, >> namely the state (inside the f), to construct the second one. You can >> do >> that in a Monad, but not in an Applicative. > > I don't think that's true, although I'm yet to decide if Applicative for > State is possible. > > someState <*> someOtherState should take the value out of the first > state, take the value out of the second state, apply one to the other, > and return a new stateful value as the result. At no point in that > description do I make mention of the previous state of one of these > values. That would be incompatible with the ap of the monad where it exists, but it's worse than that. Which state will you return? If you return one of the states output by one or other of the arguments, you'll break one of the laws: pure id <*> v = v u <*> pure y = pure ($ y) <*> u You're forced to return the input state, so the Applicative would just be an obfuscated Reader. From monnier at iro.umontreal.ca Fri Dec 5 12:35:18 2008 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Fri Dec 5 12:28:51 2008 Subject: [Haskell-cafe] Re: Gluing pipes References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> Message-ID: > \ x y -> f (g x) (h y) [...] > f $. g ~> h ~> id I keep help wonder: other than a "5 chars", what is it we have gained? Stefan From tom.davie at gmail.com Fri Dec 5 12:50:54 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 12:44:16 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: <1228495592.10115.296.camel@localhost> References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> <9E633387-15B8-4C49-ADC3-18F23FB3F9FD@gmail.com> <1228492842.10115.289.camel@localhost> <1228495592.10115.296.camel@localhost> Message-ID: On 5 Dec 2008, at 17:46, Duncan Coutts wrote: > On Fri, 2008-12-05 at 17:06 +0100, Thomas Davie wrote: >> On 5 Dec 2008, at 17:00, Duncan Coutts wrote: >> >>> On Fri, 2008-12-05 at 16:50 +0100, Thomas Davie wrote: >>> >>>> Sure, and he could then use a fold instead of a map. Reading files >>>> is >>>> problematic, but as long as you're only doing it once (the most >>>> common >>>> situation) is entirely fine wrapped up in an unsafePerformIO. >>> >>> Nooooo! >>> >>> Please don't go telling people it's entirely fine to use >>> unsafePerformIO >>> like that (or at all really). >> >> Exactly what isn't fine about it? > > It's the antithesis of pure functional programming. It's so unsafe > that > we don't even have a semantics for it. Yes, but we also don't have semantics for IO, so it's no real surprise that we have none for something that runs an IO action. > One needs pretty special justification for using unsafePerformIO and > such cases should be hidden in libraries presenting pure interfaces, > not > used willy-nilly in general application code. > > Note that I'm not claiming that it's necessarily going to do bad > things > in the specific case you're imagining using it in. However just > because > it happens not to do bad things in this case does not mean that it's > ok > to use it here or in general. No, and I never said that it should be used more generally -- I was very careful that in this case I was following the rules for making sure that verifyItsSafeYourselfPerformIO was indeed safe. Bob From martijn at van.steenbergen.nl Fri Dec 5 12:52:31 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Dec 5 12:45:48 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: <20081205155359.GA3690@soi.city.ac.uk> References: <49394A57.50405@van.steenbergen.nl> <20081205155359.GA3690@soi.city.ac.uk> Message-ID: <49396A5F.6070104@van.steenbergen.nl> Ross Paterson wrote: > Yes, because you need part of the value generated by the first computation, > namely the state (inside the f), to construct the second one. You can do > that in a Monad, but not in an Applicative. This makes me wonder: does that mean there is no such thing as an applicative transformer? Martijn. From tom.davie at gmail.com Fri Dec 5 12:56:46 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 5 12:50:03 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: <20081205171852.GA4619@soi.city.ac.uk> References: <49394A57.50405@van.steenbergen.nl> <20081205155359.GA3690@soi.city.ac.uk> <20081205171852.GA4619@soi.city.ac.uk> Message-ID: <18259566-3083-4EE9-BE7D-14824EBD51FB@gmail.com> > > That would be incompatible with the ap of the monad where it exists, > but it's worse than that. Which state will you return? If you return > one of the states output by one or other of the arguments, you'll > break > one of the laws: > > pure id <*> v = v > u <*> pure y = pure ($ y) <*> u > > You're forced to return the input state, so the Applicative would just > be an obfuscated Reader. Which reminds me ofc, that there is a valid applicative for states (assuming the monad instance is valid): instance Applicative (StateT s f) where pure = return (<*>) = ap All monads are also applicatives ;) Bob From bulat.ziganshin at gmail.com Fri Dec 5 12:57:26 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Dec 5 12:50:55 2008 Subject: [Haskell-cafe] Re: Gluing pipes In-Reply-To: References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> Message-ID: <1585425028.20081205205726@gmail.com> Hello Stefan, Friday, December 5, 2008, 8:35:18 PM, you wrote: >> \ x y -> f (g x) (h y) > [...] >> f $. g ~> h ~> id > I keep help wonder: other than a "5 chars", what is it we have gained? Haskell programmers would be paid more :D -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jonathanccast at fastmail.fm Fri Dec 5 13:01:53 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Dec 5 12:55:04 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> <67674B1E-82AC-441D-94B6-A78A9903BEC5@gmail.com> <9E633387-15B8-4C49-ADC3-18F23FB3F9FD@gmail.com> <1228492842.10115.289.camel@localhost> <1228495592.10115.296.camel@localhost> Message-ID: <1228500113.20441.18.camel@jcchost> On Fri, 2008-12-05 at 18:50 +0100, Thomas Davie wrote: > On 5 Dec 2008, at 17:46, Duncan Coutts wrote: > > > On Fri, 2008-12-05 at 17:06 +0100, Thomas Davie wrote: > >> On 5 Dec 2008, at 17:00, Duncan Coutts wrote: > >> > >>> On Fri, 2008-12-05 at 16:50 +0100, Thomas Davie wrote: > >>> > >>>> Sure, and he could then use a fold instead of a map. Reading files > >>>> is > >>>> problematic, but as long as you're only doing it once (the most > >>>> common > >>>> situation) is entirely fine wrapped up in an unsafePerformIO. > >>> > >>> Nooooo! > >>> > >>> Please don't go telling people it's entirely fine to use > >>> unsafePerformIO > >>> like that (or at all really). > >> > >> Exactly what isn't fine about it? > > > > It's the antithesis of pure functional programming. It's so unsafe > > that > > we don't even have a semantics for it. > Yes, but we also don't have semantics for IO, so it's no real surprise > that we have none for something that runs an IO action. We don't have a (denotational) semantics for Haskell, either. But, in principle, one could be produced if desired. The pure subset is easy; IO only requires a semantics for the underlying OS and --- in the presence of the FFI --- the C language. Unless you add unsafePerformIO or evaluate to the language. I think that, if someone was sufficiently motivated to work out the details, that you could prove that there is *no* denotational semantics for IO which admits either function without changing the definition of one or more pure Haskell types. jcc From ross at soi.city.ac.uk Fri Dec 5 13:02:39 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Dec 5 12:55:55 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: <18259566-3083-4EE9-BE7D-14824EBD51FB@gmail.com> References: <49394A57.50405@van.steenbergen.nl> <20081205155359.GA3690@soi.city.ac.uk> <20081205171852.GA4619@soi.city.ac.uk> <18259566-3083-4EE9-BE7D-14824EBD51FB@gmail.com> Message-ID: <20081205180239.GA5150@soi.city.ac.uk> On Fri, Dec 05, 2008 at 06:56:46PM +0100, Thomas Davie wrote: > Which reminds me ofc, that there is a valid applicative for states > (assuming the monad instance is valid): > > instance Applicative (StateT s f) where > pure = return > (<*>) = ap > > All monads are also applicatives ;) Sure, as long as you add the assumption Monad f. From ross at soi.city.ac.uk Fri Dec 5 13:25:39 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Dec 5 13:18:55 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: <49396A5F.6070104@van.steenbergen.nl> References: <49394A57.50405@van.steenbergen.nl> <20081205155359.GA3690@soi.city.ac.uk> <49396A5F.6070104@van.steenbergen.nl> Message-ID: <20081205182539.GB5150@soi.city.ac.uk> On Fri, Dec 05, 2008 at 06:52:31PM +0100, Martijn van Steenbergen wrote: > Ross Paterson wrote: >> Yes, because you need part of the value generated by the first computation, >> namely the state (inside the f), to construct the second one. You can do >> that in a Monad, but not in an Applicative. > > This makes me wonder: does that mean there is no such thing as an > applicative transformer? StateT isn't an applicative transformer, but ErrorT, ReaderT and WriterT are, and there are others that don't correspond to monad transformers, starting with product and composition. The accumulating exceptions applicative (originally due to Duncan Coutts) generalizes to a transformer. Underneath the permutation phrase parser of Arthur Baars, Andres L?h and Doaitse Swierstra is an applicative transformer. From ryani.spam at gmail.com Fri Dec 5 13:26:22 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Dec 5 13:19:36 2008 Subject: [Haskell-cafe] instance Applicative f => Applicative (StateT s f) In-Reply-To: <49396A5F.6070104@van.steenbergen.nl> References: <49394A57.50405@van.steenbergen.nl> <20081205155359.GA3690@soi.city.ac.uk> <49396A5F.6070104@van.steenbergen.nl> Message-ID: <2f9b2d30812051026v48f52ff8k72440ec85becf7b3@mail.gmail.com> > This makes me wonder: does that mean there is no such thing as an > applicative transformer? Applicative functors compose much more simply than monads, so you don't need transformers. > newtype Compose f g a = O (f (g a)) > unO (O x) = x > instance (Functor f, Functor g) => Functor (Compose f g) where > fmap f o = O $ fmap (fmap f) $ unO o > instance (Applicative f, Applicative g) => Applicative (Compose f g) where > pure x = O $ pure $ pure x > > -- unO of :: f (g (a -> b)) > -- unO ox :: f (g a) > -- to get result :: f (g b) > -- we need to lift of to f (g a -> g b) > -- which we do via (fmap (<*>)) :: f (g (a -> b)) -> f (g a -> g b) > of <*> ox = O ((<*>) <$> unO of <*> unO ox) Prettier implementations of this are available in the TypeCompose library. -- ryan From ryani.spam at gmail.com Fri Dec 5 13:43:37 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Dec 5 13:36:53 2008 Subject: [Haskell-cafe] efficient combination of foldl' and foldr -> foldl'r In-Reply-To: References: Message-ID: <2f9b2d30812051043l61698aa3l8c21decb1c087e1d@mail.gmail.com> You're testing the interpreted code, so it's not surprising that the naive version performs better; the interpretive overhead only applies to your bit of glue code. So, you've succeeded in showing that compiled code performs better than interpreted code, congratulations! :) A better test would be to write "main" that does the calculation and compile with -O2. You can then use plain old command line tools to test the timing. Alternatively, at least compile the module with optimizations before running it in ghci: ryani$ ghc -ddump-simpl -O2 -c foldlr.hs >foldlr.core (This gives you "functional assembly language" to look at for examining code generation) ryani$ ghci foldlr.hs [...] Prelude FoldLR> :set +s Prelude FoldLR> test (1000000,'a') (0.39 secs, 70852332 bytes) Prelude FoldLR> testNaive (1000000,'a') (0.42 secs, 105383824 bytes) -- ryan On Fri, Dec 5, 2008 at 7:04 AM, Henning Thielemann wrote: > > I want to do a foldl' and a foldr in parallel on a list. I assumed it would > be no good idea to run foldl' and foldr separately, because then the input > list must be stored completely between the calls of foldl' and foldr. I > wanted to be clever and implemented a routine which does foldl' and foldr in > one go. But surprisingly, at least in GHCi, my clever routine is less > efficient than the naive one. > > Is foldl'rNaive better than I expect, or is foldl'r worse than I hope? > > > module FoldLR where > > import Data.List (foldl', ) > import Control.Arrow (first, second, (***), ) > > foldl'r, foldl'rNaive :: > (b -> a -> b) -> b -> (c -> d -> d) -> d -> [(a,c)] -> (b,d) > > foldl'r f b0 g d0 = > first ($b0) . > foldr (\(a,c) ~(k,d) -> (\b -> k $! f b a, g c d)) (id,d0) > > foldl'rNaive f b g d xs = > (foldl' f b *** foldr g d) $ unzip xs > > test, testNaive :: (Integer, Char) > test = > second last $ foldl'r (+) 0 (:) "" $ replicate 1000000 (1,'a') > {- > *FoldLR> test > (1000000,'a') > (2.65 secs, 237509960 bytes) > -} > > > testNaive = > second last $ foldl'rNaive (+) 0 (:) "" $ replicate 1000000 (1,'a') > {- > *FoldLR> testNaive > (1000000,'a') > (0.50 secs, 141034352 bytes) > -} > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Fri Dec 5 14:29:52 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Dec 5 14:23:07 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <4938529F.5030708@van.steenbergen.nl> References: <49385178.2040207@btinternet.com> <4938529F.5030708@van.steenbergen.nl> Message-ID: <49398130.106@btinternet.com> Martijn van Steenbergen wrote: > Andrew Coppin wrote: >> It seems that the "correct" course of action is to design a DSL for >> declaratively describing animated line art. Does anybody have ideas >> about what such a thing might look like? > > You could take a look at Fran [1] and Yampa [2] which both seem to do > animations in Haskell. > > [1] http://conal.net/Fran/ > [2] http://www.haskell.org/yampa/ I don't think either of them will do precisely what I want, but they give me lots of useful stuff to think about. PS. The flying heads were disturbing though. PPS. "Yampa is still in active development. [...] This page last updated March 22 2004." From andrewcoppin at btinternet.com Fri Dec 5 14:32:26 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Dec 5 14:25:39 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> References: <49385178.2040207@btinternet.com> <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> Message-ID: <493981CA.3050209@btinternet.com> Tim Docker wrote: > Someone else already mentioned FRAN and it's ilk. But perhaps you don't > need something that fancy. If you implement your drawing logic as a > function from time to the appropriate render actions, ie > > | import qualified Graphics.Rendering.Cairo as C > | > | type Animation = Time -> C.Render () > > then you just need to call this function multiple times to generate > sucessive frames. > That was my initial idea... but I'm not sure how well it would work. I want to do stuff like fade elements in and out, move complex structures around on the screen, etc. I think it might end up being a little tangled if I go with this approach. I might be wrong though... From andrewcoppin at btinternet.com Fri Dec 5 14:34:50 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Dec 5 14:28:04 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <7BC4BD5C-51C5-4234-8FFE-4BA330EF0F0A@anu.edu.au> References: <49385178.2040207@btinternet.com> <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> <7BC4BD5C-51C5-4234-8FFE-4BA330EF0F0A@anu.edu.au> Message-ID: <4939825A.40509@btinternet.com> Ben Lippmeier wrote: > The ANUPlot graphics library I wrote does exactly this. > The darcs repo is at http://code.haskell.org/ANUPlot/ANUPlot-HEAD/ > It comes with lots of examples that do the sort of things you describe. Does it handle drawing lines and circles (with antialiasing)? Can I save the output as PNG? From ashley at semantic.org Fri Dec 5 14:36:44 2008 From: ashley at semantic.org (Ashley Yakeley) Date: Fri Dec 5 14:29:59 2008 Subject: [Haskell-cafe] Re: deleting spam on the wiki In-Reply-To: <1228491451.10115.277.camel@localhost> References: <1228491451.10115.277.camel@localhost> Message-ID: <1228505804.8782.1.camel@glastonbury> You can blank the page but you cannot delete it. I'll delete the pages and block the user/IP address later today. -- Ashley On Fri, 2008-12-05 at 15:37 +0000, Duncan Coutts wrote: > Who is able to delete wiki spam? > > http://haskell.org/haskellwiki/?title=Special:Contributions&target=Tomso123 > > All the pages created by this user appear to be spam (check the google > translation) so the account should probably be deleted too. > > As I understand it, any registered user can revert changes to a page: > http://www.haskell.org/haskellwiki/Help:Editing > > However if a registered user creates new spam pages then other ordinary > registered users cannot revert that change. > > Is there some way of reporting spam pages to the appropriate people that > I missed? > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081205/8d352ded/attachment.htm From andrewcoppin at btinternet.com Fri Dec 5 15:01:43 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Dec 5 14:54:56 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <49385178.2040207@btinternet.com> References: <49385178.2040207@btinternet.com> Message-ID: <493988A7.9040405@btinternet.com> Today I sat down and had a think about this problem. After reading about various FRP systems (Yampa et al) I had a few ideas in my head. The main idea is that I want to be able to draw lines and curves and so forth, and I want to add them to and remove them from the display at various times, and move them around, change their colour and opacity, etc. I also want to be able to run one piece of animation, and then another, and then another. So I want some sort of sequencing primitives. I had a go at writing what I thought the interface might look like. (Fortunately, I made no attempt to *implement* it - otherwise I would doubtless have wasted huge amounts of time implementing something that isn't designed right yet!) Unfortunately Haskell doesn't really provide a way to write an "interface", and then write the implementation behind it seperately somewhere else. So the "code" I wrote wasn't actually compilable at all, but it was useful to sketch something out. My initial idea was that I could have some kind of monad for controlling adding and removing stuff. The monad could provide an "add" action that adds a visual object to the frame and returns a unique ID. Then you could have a "remove" action that removes the specified ID again. And a "wait" action that makes the display stay the same for so many seconds. (But the visual objects may internally be animated.) Then I hit upon the idea that maybe one thread of control could "spawn" a second one - so that for example one thread could generate a bunch of snowflakes raining down the screen while a seperate thread rotates a geometric figure in the center. Or something. Of course, these "threads" have no need (or use) for actually running concurrently - they are only "concurrent" in the sence that they both affect the same frame, rather than their actions happening one after another on consecutive frames. Next I got to thinking that maybe these threads of control might need to communicate for synchronisation. E.g., when a rotating line reaches 90? with another line, a signal is sent to another thread, which then adds another visual element or stops the animation or something. The parent thread *could* algebraicly _compute_ what time this will happen, but sending a signal is much simpler. (E.g., if you change the speed of an animation, the threads still stay synchronised without you having to remember to adjust parameters in your calculations all over the place...) There's still one little problem though. The "threads of control" are for sequencing stuff. They are inherantly discrete; *add* this thing, *remove* this other thing, *send* this signal, *wait* to receive a signal, etc. But something like, say, rotating a line, is inherantly continuous. So there's a discrete system for sequencing stuff - which I seem to have worked out fairly well - and there also needs to be a continuous system for doing all the things with are smooth functions of time. So maybe the continuous stuff should just be a type alias to a regular Haskell function? Ah, but wait... I said I might want to send a signal when an animation reaches a specific stage, right? So these "functions" need to do more than just map time to some other variable; they need to be able to send signals. And hey, actually, what are the chances of a time sample exactly lining up with the instant that the notable event occurs? How do I want to handle that? ...and at this point, it was time to go home! :-D From hjgtuyl at chello.nl Fri Dec 5 15:25:28 2008 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Fri Dec 5 15:18:40 2008 Subject: [Haskell-cafe] Re: deleting spam on the wiki In-Reply-To: <1228505804.8782.1.camel@glastonbury> References: <1228491451.10115.277.camel@localhost> <1228505804.8782.1.camel@glastonbury> Message-ID: I already added the category "Pages to be removed" to these pages, so they turn up on page: http://haskell.org/haskellwiki/Category:Pages_to_be_removed There are are other pages in this category. Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- On Fri, 05 Dec 2008 20:36:44 +0100, Ashley Yakeley wrote: > You can blank the page but you cannot delete it. I'll delete the pages > and block the user/IP address later today. > > -- Ashley > > On Fri, 2008-12-05 at 15:37 +0000, Duncan Coutts wrote: > >> Who is able to delete wiki spam? >> >> http://haskell.org/haskellwiki/?title=Special:Contributions&target=Tomso123 >> >> All the pages created by this user appear to be spam (check the google >> translation) so the account should probably be deleted too. >> >> As I understand it, any registered user can revert changes to a page: >> http://www.haskell.org/haskellwiki/Help:Editing >> >> However if a registered user creates new spam pages then other ordinary >> registered users cannot revert that change. >> >> Is there some way of reporting spam pages to the appropriate people that >> I missed? >> >> Duncan >> >> -- From tphyahoo at gmail.com Fri Dec 5 15:39:14 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Dec 5 15:32:29 2008 Subject: sending email via gmail Re: [Haskell-cafe] Sending email from a Haskell program Message-ID: <910ddf450812051239m6062d8erd8d89ce3bad87de8@mail.gmail.com> I ran into this problem when I wanted to send email from a HAppS web app, routing it through gmail. There actually used to be an SMTP client in HAppS but it was dropped a while ago. The most common workaround appears to be, just use sendmail. But I couldn't figure out a way to get sendmail to interface with gmail. (I think there is a way, there are blogs on it, I just wasn't patient enough to follow the directions.) What I finally did is, I have successfully followed the instructions in http://www.ericstockwell.com/?p=3 to send myself email from the command line. So I will probably use HSH to run shell commands in my haskell web apps, to send email. This process only took a few minutes, and seemed easier than the postfix/sendmail solutions I came across. Of course, this only works in unixy environments. thomas. 2007/9/27 brad clawsie : >> jmuk's HaskellNet project from last year? >> >> http://darcs.haskell.org/SoC/haskellnet/HaskellNet/IMAP.hs > > sweet! was there any documentation created for this? examples? > anything? have people tried to make this work with ssl/tls libs? > > by the way there looks like some other gems in the haskellnet > dir. what exactly was haskellnet - a project to code to the major > network protocols? are these libs stable? how does the HTTP lib stack > up against Network.HTTP? any info on this project would be > appreciated. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From martijn at van.steenbergen.nl Fri Dec 5 16:10:39 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Dec 5 16:03:53 2008 Subject: [Haskell-cafe] Can't cabal install readline Message-ID: <493998CF.60904@van.steenbergen.nl> Hello, This week I upgraded to GHC 6.10 using the .pkg installer. It installed without a single hiccup -- thanks! I've noticed two odd things: the standard library haddock that comes with the installer doesn't have links to the hs-coloured sources anymore (and neither does the online documentation); I miss that a lot. I also can't Ctrl+R anymore in GHCi to search my command history. But I can learn to live without those. Another minor inconvenience is that the packages I had installed (using cabal) are no longer available to GHC -- I think I will have to reinstall them. But I cannot continue working on my Yogurt project anymore, because it depends on readline, which fails to build: checking for rl_readline_version... yes checking for rl_begin_undo_group... no configure: error: readline not found, so this package cannot be built See `config.log' for more details. cabal: Error: some packages failed to install: Yogurt-0.2 depends on readline-1.0.1.0 which failed to install. readline-1.0.1.0 failed during the configure step. The exception was: exit: ExitFailure 1 The build failure mentions config.log which I cannot find anywhere on my system. I have readline installed using MacPorts without problems, and the cabal package worked fine too on the previous version of GHC. I'm on Intel Leopard. How can I get cabal install readline to succeed on the new GHC? Thanks much, Martijn. From judah.jacobson at gmail.com Fri Dec 5 17:08:35 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Fri Dec 5 17:01:50 2008 Subject: [Haskell-cafe] Can't cabal install readline In-Reply-To: <493998CF.60904@van.steenbergen.nl> References: <493998CF.60904@van.steenbergen.nl> Message-ID: <6d74b0d20812051408u18d8df80yd5ea066a770557ca@mail.gmail.com> On Fri, Dec 5, 2008 at 1:10 PM, Martijn van Steenbergen wrote: > Hello, > > This week I upgraded to GHC 6.10 using the .pkg installer. It installed > without a single hiccup -- thanks! > > I've noticed two odd things: the standard library haddock that comes with > the installer doesn't have links to the hs-coloured sources anymore (and > neither does the online documentation); I miss that a lot. I also can't > Ctrl+R anymore in GHCi to search my command history. But I can learn to live > without those. The following instructions should re-enable Ctrl-R: http://mult.ifario.us/p/editrc-tidbit-for-ghci > Another minor inconvenience is that the packages I had installed (using > cabal) are no longer available to GHC -- I think I will have to reinstall > them. But I cannot continue working on my Yogurt project anymore, because it > depends on readline, which fails to build: > > > checking for rl_readline_version... yes > checking for rl_begin_undo_group... no > configure: error: readline not found, so this package cannot be built > See `config.log' for more details. > cabal: Error: some packages failed to install: > Yogurt-0.2 depends on readline-1.0.1.0 which failed to install. > readline-1.0.1.0 failed during the configure step. The exception was: > exit: ExitFailure 1 The above happens because GHC is using the OS X default installation of libreadline.a which is actually a link to libedit that doesn't implement the full readline API. If you already have the MacPorts readline, you just need to tell cabal where it is, with (for example) cabal install readline --extra-include-dirs=/opt/local/include --extra-lib-dirs=/opt/local/lib -Judah From matt at immute.net Fri Dec 5 17:40:26 2008 From: matt at immute.net (Matt Hellige) Date: Fri Dec 5 17:33:40 2008 Subject: [Haskell-cafe] Re: Gluing pipes In-Reply-To: References: <5959041b0812031017m73967563nf8934098613134da@mail.gmail.com> Message-ID: <5959041b0812051440v45474c1esf49de0f5e4a7d94c@mail.gmail.com> On Fri, Dec 5, 2008 at 11:35 AM, Stefan Monnier wrote: >> \ x y -> f (g x) (h y) > [...] >> f $. g ~> h ~> id > > I keep help wonder: other than a "5 chars", what is it we have gained? Certainly in such a simple case, there's no benefit. In more complex cases, especially where we're focused on just writing the combinator itself (i.e., in cases where we won't use ($.)), I think it might make sense (there is an example in the comments of Conal's recent post at [1]). But anyway I do mean "might"... I happily admit the possibility that this may be nothing more than a curiosity. I'm happy to have found a solution to my little puzzle, but I'm not sure how often I'll actually use it. Time will tell, I suppose. Matt From lemming at henning-thielemann.de Fri Dec 5 17:43:10 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Dec 5 17:36:25 2008 Subject: [Haskell-cafe] efficient combination of foldl' and foldr -> foldl'r In-Reply-To: <2f9b2d30812051043l61698aa3l8c21decb1c087e1d@mail.gmail.com> References: <2f9b2d30812051043l61698aa3l8c21decb1c087e1d@mail.gmail.com> Message-ID: On Fri, 5 Dec 2008, Ryan Ingram wrote: > You're testing the interpreted code, so it's not surprising that the > naive version performs better; the interpretive overhead only applies > to your bit of glue code. I wanted to avoid the optimizer to do clever things itself. > Alternatively, at least compile the module with optimizations before > running it in ghci: > > ryani$ ghc -ddump-simpl -O2 -c foldlr.hs >foldlr.core > (This gives you "functional assembly language" to look at for > examining code generation) > > ryani$ ghci foldlr.hs > [...] > Prelude FoldLR> :set +s > Prelude FoldLR> test > (1000000,'a') > (0.39 secs, 70852332 bytes) > Prelude FoldLR> testNaive > (1000000,'a') > (0.42 secs, 105383824 bytes) There is still no clear advantage of foldl'r compared to foldl'rNaive, is it? From philip.weaver at gmail.com Fri Dec 5 17:46:20 2008 From: philip.weaver at gmail.com (Philip Weaver) Date: Fri Dec 5 17:39:35 2008 Subject: [Haskell-cafe] Can't cabal install readline In-Reply-To: <6d74b0d20812051408u18d8df80yd5ea066a770557ca@mail.gmail.com> References: <493998CF.60904@van.steenbergen.nl> <6d74b0d20812051408u18d8df80yd5ea066a770557ca@mail.gmail.com> Message-ID: On Fri, Dec 5, 2008 at 2:08 PM, Judah Jacobson wrote: > On Fri, Dec 5, 2008 at 1:10 PM, Martijn van Steenbergen > wrote: > > Hello, > > > > This week I upgraded to GHC 6.10 using the .pkg installer. It installed > > without a single hiccup -- thanks! > > > > I've noticed two odd things: the standard library haddock that comes with > > the installer doesn't have links to the hs-coloured sources anymore (and > > neither does the online documentation); I miss that a lot. I also can't > > Ctrl+R anymore in GHCi to search my command history. But I can learn to > live > > without those. > > The following instructions should re-enable Ctrl-R: > > http://mult.ifario.us/p/editrc-tidbit-for-ghci > > > Another minor inconvenience is that the packages I had installed (using > > cabal) are no longer available to GHC -- I think I will have to > reinstall > > them. But I cannot continue working on my Yogurt project anymore, because > it > > depends on readline, which fails to build: > > > > > > checking for rl_readline_version... yes > > checking for rl_begin_undo_group... no > > configure: error: readline not found, so this package cannot be built > > See `config.log' for more details. > > cabal: Error: some packages failed to install: > > Yogurt-0.2 depends on readline-1.0.1.0 which failed to install. > > readline-1.0.1.0 failed during the configure step. The exception was: > > exit: ExitFailure 1 > > > The above happens because GHC is using the OS X default installation > of libreadline.a which is actually a link to libedit that doesn't > implement the full readline API. > > If you already have the MacPorts readline, you just need to tell cabal > where it is, with (for example) > > cabal install readline --extra-include-dirs=/opt/local/include > --extra-lib-dirs=/opt/local/lib > If you'd like, you can add /opt/local/include to your shell's INCLUDE_PATH and/or C_INCLUDE_PATH environment variables and /opt/local/lib to your LIBRARY_PATH and/or LD_LIBRARY_PATH variables. I say "and/or" because I don't know which one is actually necessary, but if you add it to both you'll be safe. - Phil > > -Judah > _______________________________________________ > 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/20081205/04a62a37/attachment.htm From mail at joachim-breitner.de Fri Dec 5 17:54:56 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Fri Dec 5 17:48:13 2008 Subject: [Haskell-cafe] efficient combination of foldl' and foldr -> foldl'r In-Reply-To: References: <2f9b2d30812051043l61698aa3l8c21decb1c087e1d@mail.gmail.com> Message-ID: <1228517696.14187.29.camel@otto.ehbuehl.net> Hi, Am Freitag, den 05.12.2008, 23:43 +0100 schrieb Henning Thielemann: > > ryani$ ghci foldlr.hs > > [...] > > Prelude FoldLR> :set +s > > Prelude FoldLR> test > > (1000000,'a') > > (0.39 secs, 70852332 bytes) > > Prelude FoldLR> testNaive > > (1000000,'a') > > (0.42 secs, 105383824 bytes) > > There is still no clear advantage of foldl'r compared to foldl'rNaive, is > it? Maybe not directly speed-wise, but the memory consumption is reduced by 30% (probably due to laziness, and unless I misreading ghci?s output) Greetings, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081205/5beafdbc/attachment.bin From dokondr at gmail.com Fri Dec 5 18:13:31 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Fri Dec 5 18:06:46 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <493859E0.1030702@van.steenbergen.nl> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> Message-ID: <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> On Fri, Dec 5, 2008 at 1:29 AM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > Dmitri O.Kondratiev wrote: > >> -- How to define Show [MyType] ? >> > > Define instance Show MyType and implement not only show (for 1 value of > MyType) but also showList, which Show provides as well. You can do all the > magic in there. > > HTH, > > Martijn. > > Thanks everybody for your help! I tried to implement showList, but get the same error: {-- -- from Prelude: type *ShowS* = String-> String *showList* :: [a] -> ShowS --} myShows::ShowS myShows s = s ++ "\n" data ShipInfo = Ship { name :: String, kind :: String, canons :: Int } deriving Show -- I get this error again: instance (Show [ShipInfo]) where showList [] = myShows [] showList (x:xs) = myShows "x" ++ showList xs Illegal instance declaration for `Show [ShipInfo]' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Show [ShipInfo]' Failed, modules loaded: none. -- What am I doing wrong? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081206/c95e1f75/attachment-0001.htm From Ben.Lippmeier at anu.edu.au Fri Dec 5 18:15:18 2008 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Fri Dec 5 18:08:36 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <4939825A.40509@btinternet.com> References: <49385178.2040207@btinternet.com> <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> <7BC4BD5C-51C5-4234-8FFE-4BA330EF0F0A@anu.edu.au> <4939825A.40509@btinternet.com> Message-ID: <79B7C603-42A5-4BF8-B7C8-FEC768611965@anu.edu.au> On 06/12/2008, at 6:34 AM, Andrew Coppin wrote: > Ben Lippmeier wrote: >> The ANUPlot graphics library I wrote does exactly this. >> The darcs repo is at http://code.haskell.org/ANUPlot/ANUPlot-HEAD/ >> It comes with lots of examples that do the sort of things you >> describe. > > Does it handle drawing lines and circles (with antialiasing)? Can I > save the output as PNG? Lines and circles yes, antialiasing no. It uses OpenGL for rendering, so maybe there's a flag to turn it on. PNG isn't usually required for animations. When I need to make an image I just do a screenshot. Ben. From hpacheco at gmail.com Fri Dec 5 18:18:37 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Fri Dec 5 18:11:52 2008 Subject: [Haskell-cafe] Fun with type functions In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C33281447D7F@EA-EXMSG-C334.europe.corp.microsoft.com> References: <638ABD0A29C8884A91BC5FB5C349B1C33281447D7F@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <7b92c2840812051518s34122297o9a2f2cdcbe65841@mail.gmail.com> Pointless Haskell a library for point-free programming with recursion patterns that uses type synonym families to provide a view of data types as the fixed points of functors. It defines two type functions type family PF a :: * -> * -- returns the pattern functor for a data type type family Rep (f :: * -> *) x :: * -- returns the result type of applying a functor to a type argument that can be combined to derive the structurally equivalent sum of products for some type: type F a x = Rep (PF a) x class Mu a where inn :: F a a -> a out :: a -> F a a For Haskell polymorphic lists, we need to define: type instance PF [a] = Const One :+: Const a :*: Id instance Mu [a] where inn (Left _) = [] inn (Right (x,xs)) = x:xs out [] = Left _L out (x:xs) = Right (x,xs) Some of the typical recursion patterns are: hylo :: Functor (PF b) => b -> (F b c -> c) -> (a -> F b a) -> a -> c cata :: (Mu a,Functor (PF a)) => a -> (F a b -> b) -> a -> b ana :: (Mu b,Functor (PF b)) => b -> (a -> F b a) -> a -> b One simple example is the foldr (catamorphism) for calculating the lenght of a list: length :: [a] -> Int length = cata (_L::[a]) f where f = zero \/ succ . snd > length [1,2,3,4] 4 I have promoted the library into a cabal package (pointless-haskell) today and am creating an homepage ( http://haskell.di.uminho.pt/wiki/Pointless+Haskell) with examples. cheers, hugo On Thu, Nov 27, 2008 at 9:29 AM, Simon Peyton-Jones wrote: > Friends > > GHC has embodied data type families since 6.8, and now type synonym > families (aka type functions) in 6.10. However, apart from our initial > papers there isn't much published material about how to *use* type families. > But that hasn't stopped you: quite a few people are using them already, and > of course there is a rich seam of work on using functional dependencies to > express type-level computation. > > Ken Shan and Oleg Kiselyov and I are collaborating to write a paper for an > upcoming workshop, under the general rubric of "Fun with type functions" (in > homage to Thomas Hallgren's paper "Fun with functional dependencies" and > Ralf Hinze's paper "Fun with phantom types"). > > So this message is to ask you: > > can you tell us about the most persuasive, fun application > you've encountered, for type families or functional dependencies? > > Simple is good. It doesn't have to be elaborate: just something that does > something useful you could not have done otherwise. Pointers to email > threads are fine. Don't assume we already know about them (even if we > participated in the thread :-) Part of what we're interested in is that > *you* found the example compelling. > > Many thanks > > Simon, Ken, Oleg > > PS: I'm broadcasting this message to GHC-users and Haskell-cafe, but to > avoid deluging ghc-users, please reply just to us and Haskell cafe. > (Interested ghc-users can follow the threads there from the archives if > they want.) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081205/8b572235/attachment.htm From gwern0 at gmail.com Fri Dec 5 18:18:48 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Dec 5 18:12:06 2008 Subject: [Haskell-cafe] Haskell haikus Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi everyone. So today I finally got around to something long on my todo list - a compilation of all the Haskell haikus I've seen around! It is at http://haskell.org/haskellwiki/Haiku But I'm afraid I only have 5, and Google doesn't turn up any more. So: does anybody have a haiku I missed? Or even better, is anyone feeling poetically inspired tonight? :) - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkk5ttoACgkQvpDo5Pfl1oJ+ygCfdSSBmbgyoOwkG53rKahF2Su1 84UAoIOrxGwe3u+WwnKxvKulq1AT4IJS =+2kH -----END PGP SIGNATURE----- From martijn at van.steenbergen.nl Fri Dec 5 18:25:07 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Dec 5 18:18:22 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> Message-ID: <4939B853.90808@van.steenbergen.nl> Dmitri O.Kondratiev wrote: > Thanks everybody for your help! > I tried to implement showList, but get the same error: That's because you're trying to implement instance Show [MyType], but you have to implement instance Show MyType instead, without the []. Groetjes, Martijn. From daniel.is.fischer at web.de Fri Dec 5 18:32:21 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Dec 5 18:23:17 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> Message-ID: <200812060032.21681.daniel.is.fischer@web.de> Am Samstag, 6. Dezember 2008 00:13 schrieb Dmitri O.Kondratiev: > > Thanks everybody for your help! > I tried to implement showList, but get the same error: > > {-- > -- from Prelude: > type *ShowS* = > Stringring>-> > Stringring> *showList* :: [a] -> > ShowSwS> --} > > myShows::ShowS > myShows s = s ++ "\n" > > data ShipInfo = Ship { > name :: String, > kind :: String, > canons :: Int > } deriving Show No, if you derive the Show instance for ShipInfo, it automatically implements the standard showList, too. You have to do it yourself: data ShipInfo = Ship { name :: String, kind :: String, canons :: Int } instance Show ShipInfo where showsPrec p (Ship name kind canons) = ... showList xs = showString (unlines $ map show xs) or whatever you want for showList. However, somebody said it before, the Show instance should not be used for pretty-printing. > > -- I get this error again: > instance (Show [ShipInfo]) where > showList [] = myShows [] > showList (x:xs) = myShows "x" ++ showList xs > > Illegal instance declaration for `Show [ShipInfo]' > (The instance type must be of form (T a b c) > where T is not a synonym, and a,b,c are distinct type variables) > In the instance declaration for `Show [ShipInfo]' > Failed, modules loaded: none. > > -- What am I doing wrong? > Thanks! From tphyahoo at gmail.com Fri Dec 5 19:53:42 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Dec 5 19:46:56 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: References: Message-ID: <910ddf450812051653o6a5c4eerdb0662aa666ff15b@mail.gmail.com> You come for magic silver bullets slaying bugs... It is only code! 2008/12/6 Gwern Branwen : > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > Hi everyone. So today I finally got around to something long on my > todo list - a compilation of all the Haskell haikus I've seen around! > > It is at http://haskell.org/haskellwiki/Haiku > > But I'm afraid I only have 5, and Google doesn't turn up any more. > > So: does anybody have a haiku I missed? Or even better, is anyone > feeling poetically inspired tonight? :) > > - -- > gwern > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEAREKAAYFAkk5ttoACgkQvpDo5Pfl1oJ+ygCfdSSBmbgyoOwkG53rKahF2Su1 > 84UAoIOrxGwe3u+WwnKxvKulq1AT4IJS > =+2kH > -----END PGP SIGNATURE----- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ajb at spamcop.net Fri Dec 5 21:02:54 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Fri Dec 5 20:55:39 2008 Subject: [Haskell-cafe] Re: Functional version of this OO snippet In-Reply-To: References: <258941FE-0334-4D86-8139-11B1A6155CC3@gmail.com> Message-ID: <20081205210254.7qrv0r1hq8kgggs4-nwo@webmail.spamcop.net> G'day all. Thomas Davie wrote: >> class IEngine a where >> foo :: a -> String >> bar :: a -> String -> String "Apfelmus, Heinrich" replied: > You don't even need a type class, a simple data type is enough. > > data Engine = Engine { foo :: IO (), bar :: String -> IO () } There is a tradeoff here, that you should be aware of. 1. Using typeclasses. Pro: It works with the SPECIALIZE pragma. Pro: You can put arbitrary data in the concrete data type which is the instance of IEngine. (If you don't, incidentally, this is called a "traits typeclass".) Con: You can't generate instances of IEngine dynamically at run-time (at least without using unportable unsafeCast# magic). So you're limited to only those implementations that you (possibly dynamically) link in. 2. Using records. Pro: Usually simpler, and using fewer lines of code. Pro: You can generate new "instances" at will, and you're not limited to that which you link in. Con: Usually more explicit arguments passed around. Con: If your methods involve polymorphism, then the record will turn out to have a higher-rank type, which isn't valid Haskell 98. > This always works because all object methods expect a "self" argument. That's not true for OO languages which have virtual constructors. Haskell typeclasses support virtual constructors/factory methods just fine, because the "self" type can appear anywhere in the signature, including being the return value. The monad "return" method is one example of this. Cheers, Andrew Bromage From lane at downstairspeople.org Fri Dec 5 22:00:35 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Fri Dec 5 21:53:50 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <493988A7.9040405@btinternet.com> References: <49385178.2040207@btinternet.com> <493988A7.9040405@btinternet.com> Message-ID: You may also want to at least look at RSAGL, in particular I've implemented an arrow transformer that does much of what you describe with threading, although I see that I probably need to go back and work on documentation. The basic idea revolves around giving threads an identity type that implements Eq. The parent thread can cull threads it doesn't want, while the threads themselves can spawn new threads or self-terminate. If a thread spawns a thread ID that already exists, the new duplicate is disregarded (unless you choose to provide a different behaviour). Anonymous threads are implemented using Maybe. Threads have an explicit ultimate input and output type, and can explicitly switch themselves over to another thread with matching input and output types. Both the spawn and switch directives take a continuous input, which is a list or Maybe respectively containing information about what spawn or switch should be dispatched at that moment. Since it's an arrow transformer, you can for example pass messages between threads by layering it on top of a StateArrow. I have also used a StateArrow to accumulate rendering instructions and to manage a transformation matrix context. You talk about adding and removing "things", but I don't think that's a good idea. Rather the thing's existence and disposition is a continuous function within a thread. If it assists with understanding, the StatefulArrow is a stripped down arrow transformer version of the YAMPA arrow, and the other arrows build on that functionality until you get to the FRP arrow. The git repo is browsable here: http://roguestar.downstairspeople.org/gitweb?p=rsagl.git;a=summary Relevant modules are ThreadedArrow, SwitchedArrow, StatefulArrow, FRPBase and FRP. I don't have any 2D support in RSAGL at all. Hopefully this helps and I'd also appreciate any feedback. --Lane From nicolas.frisby at gmail.com Fri Dec 5 22:23:07 2008 From: nicolas.frisby at gmail.com (Nicolas Frisby) Date: Fri Dec 5 22:16:21 2008 Subject: [Haskell-cafe] know a workaround for greedy context reduction? Message-ID: <5ce89fb50812051923j583cd86dwf09bfcf5d6ea2f46@mail.gmail.com> With these three declarations {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} class C a where c :: a class C a => D a where d :: a instance C a => D a where d = c ghci exhibits this behavior: *> :t d d :: (C a) => a Where I would prefer "d :: (D a) => a". In my actual examples, the context is much larger and I can't involve overlapping instances. Is there a known workaround? I didn't find a related bug on the GHC trac, and I don't know if other compilers behave in the same way. From nicolas.frisby at gmail.com Fri Dec 5 22:25:01 2008 From: nicolas.frisby at gmail.com (Nicolas Frisby) Date: Fri Dec 5 22:18:15 2008 Subject: [Haskell-cafe] Re: Could FDs help usurp an ATs syntactic restriction? In-Reply-To: <5ce89fb50812041938s1df748e7vdaead568b53fce9d@mail.gmail.com> References: <5ce89fb50812041938s1df748e7vdaead568b53fce9d@mail.gmail.com> Message-ID: <5ce89fb50812051925h16d97608nfb581315aecdd5cd@mail.gmail.com> Perhaps this ticket is related? http://hackage.haskell.org/trac/ghc/ticket/714 On Thu, Dec 4, 2008 at 9:38 PM, Nicolas Frisby wrote: > From the error below, I'm inferring that the RHS of the associated > type definition can only contain type variables from the instance > head, not the instance context. I didn't explicitly see this > restriction when reading the GHC/Type_families entry. > > Could perhaps the "a b -> bn" functional dependency of the TypeEq > class lift this restriction for bn? This isn't my ball park, but that > idea has my hopes up :). > > > {-# LANGUAGE TypeFamilies #-} > > import TypeEq > > -- Attempting to encapsulate TypeEq behind an associated type. > > class EQ a b where > type BN a b > > instance TypeEq a b bn => EQ a b where > type BN a b = bn > > > results in an error > > > /tmp/Test.hs:9:16: Not in scope: type variable `bn' > Failed, modules loaded: none. > > From roma at ro-che.info Sat Dec 6 02:32:57 2008 From: roma at ro-che.info (Roman Cheplyaka) Date: Sat Dec 6 02:26:45 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: References: Message-ID: <20081206073257.GB3970@flit> * Gwern Branwen [2008-12-05 18:18:48-0500] > Hi everyone. So today I finally got around to something long on my > todo list - a compilation of all the Haskell haikus I've seen around! > > It is at http://haskell.org/haskellwiki/Haiku > > But I'm afraid I only have 5, and Google doesn't turn up any more. > > So: does anybody have a haiku I missed? Or even better, is anyone > feeling poetically inspired tonight? :) IIRC, Wouter Swierstra wrote some haikus for Summer of Code issue of The Monad Reader _last year_. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From semanticphilosopher at googlemail.com Sat Dec 6 03:53:03 2008 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Sat Dec 6 03:46:44 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: References: Message-ID: <9F88A6B9-7161-43CA-886E-63F0B819D1F4@gmail.com> Yesterday it worked Today is is still working Haskell is like that! On 5 Dec 2008, at 23:18, Gwern Branwen wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > Hi everyone. So today I finally got around to something long on my > todo list - a compilation of all the Haskell haikus I've seen around! > > It is at http://haskell.org/haskellwiki/Haiku > > But I'm afraid I only have 5, and Google doesn't turn up any more. > > So: does anybody have a haiku I missed? Or even better, is anyone > feeling poetically inspired tonight? :) > > - -- > gwern > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEAREKAAYFAkk5ttoACgkQvpDo5Pfl1oJ+ygCfdSSBmbgyoOwkG53rKahF2Su1 > 84UAoIOrxGwe3u+WwnKxvKulq1AT4IJS > =+2kH > -----END PGP SIGNATURE----- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From paul at cogito.org.uk Sat Dec 6 12:05:00 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Sat Dec 6 11:58:15 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <493988A7.9040405@btinternet.com> References: <49385178.2040207@btinternet.com> <493988A7.9040405@btinternet.com> Message-ID: <493AB0BC.90204@cogito.org.uk> Andrew Coppin wrote: > So I want some sort of sequencing primitives. Sequencing generally suggests a monad. something = do { action1; delay 10; action2} > I had a go at writing what I thought the interface might look like. > (Fortunately, I made no attempt to *implement* it - otherwise I would > doubtless have wasted huge amounts of time implementing something that > isn't designed right yet!) Unfortunately Haskell doesn't really > provide a way to write an "interface", and then write the > implementation behind it seperately somewhere else. So the "code" I > wrote wasn't actually compilable at all, but it was useful to sketch > something out. When I do this I generally write functions like foo = error "foo: Not implemented yet" > My initial idea was that I could have some kind of monad for > controlling adding and removing stuff. The monad could provide an > "add" action that adds a visual object to the frame and returns a > unique ID. Then you could have a "remove" action that removes the > specified ID again. And a "wait" action that makes the display stay > the same for so many seconds. (But the visual objects may internally > be animated.) I'd suggest that each object has its own action to animate it. You will need to write a custom monad to interleave actions. See http://www.cs.chalmers.se/~koen/pubs/jfp99-monad.ps for something along the right lines. > Then I hit upon the idea that maybe one thread of control could > "spawn" a second one - so that for example one thread could generate a > bunch of snowflakes raining down the screen while a seperate thread > rotates a geometric figure in the center. Or something. Sounds right. > Of course, these "threads" have no need (or use) for actually running > concurrently - they are only "concurrent" in the sence that they both > affect the same frame, rather than their actions happening one after > another on consecutive frames. > > Next I got to thinking that maybe these threads of control might need > to communicate for synchronisation. E.g., when a rotating line reaches > 90? with another line, a signal is sent to another thread, which then > adds another visual element or stops the animation or something. The > parent thread *could* algebraicly _compute_ what time this will > happen, but sending a signal is much simpler. (E.g., if you change the > speed of an animation, the threads still stay synchronised without you > having to remember to adjust parameters in your calculations all over > the place...) Yup. I did exactly this, albeit for a very different application. Unfortunately the code belongs to my employer so I can't post it. But if you look at the paper above and also read about the "ContT" monad you will get the right idea. Its a bit mind-bending, but you suspend a thread by getting its continuation (using callCC) and stuffing it into whatever data structure is being used to hold pending threads (e.g. a semaphore queue). Or you could use the existing concurrent threads mechanism, which is kludgier but less work. > There's still one little problem though. The "threads of control" are > for sequencing stuff. They are inherantly discrete; *add* this thing, > *remove* this other thing, *send* this signal, *wait* to receive a > signal, etc. But something like, say, rotating a line, is inherantly > continuous. So there's a discrete system for sequencing stuff - which > I seem to have worked out fairly well - and there also needs to be a > continuous system for doing all the things with are smooth functions > of time. Thats where Reactive stuff comes in. > > So maybe the continuous stuff should just be a type alias to a regular > Haskell function? Ah, but wait... I said I might want to send a signal > when an animation reaches a specific stage, right? So these > "functions" need to do more than just map time to some other variable; > they need to be able to send signals. And hey, actually, what are the > chances of a time sample exactly lining up with the instant that the > notable event occurs? How do I want to handle that? Events are part of reactive frameworks. Paul. From gwern0 at gmail.com Sat Dec 6 12:18:50 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Dec 6 12:12:02 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: <20081206073257.GB3970@flit> References: <20081206073257.GB3970@flit> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Sat, Dec 6, 2008 at 2:32 AM, Roman Cheplyaka wrote: > * Gwern Branwen [2008-12-05 18:18:48-0500] >> Hi everyone. So today I finally got around to something long on my >> todo list - a compilation of all the Haskell haikus I've seen around! >> >> It is at http://haskell.org/haskellwiki/Haiku >> >> But I'm afraid I only have 5, and Google doesn't turn up any more. >> >> So: does anybody have a haiku I missed? Or even better, is anyone >> feeling poetically inspired tonight? :) > > IIRC, Wouter Swierstra wrote some haikus for Summer of Code issue of The > Monad Reader _last year_. So he did; I had only remembered the TMR limericks for this year. (This point, incidentally, raises a hobbyhorse of mine - Google didn't see the TMR haikus because they were in PDF. I am certain if the articles and the introduction had been wikified, they would've turned up in my searches. Someday...) - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkk6s/kACgkQvpDo5Pfl1oLzIgCggdbuyVNAikyZ1FyCvrMBLZYe C3YAnjnq5nIjYkmuqdbcnCA+eHHLwrlL =KhVj -----END PGP SIGNATURE----- From malcolm.wallace at cs.york.ac.uk Sat Dec 6 12:50:00 2008 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Sat Dec 6 12:47:43 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: References: <20081206073257.GB3970@flit> Message-ID: <4750D097-8031-4147-AD13-694DA15888FC@cs.york.ac.uk> > (This point, incidentally, raises a hobbyhorse of mine - Google didn't > see the TMR haikus because they were in PDF. How odd. Googling for "haskell haiku TMR" brings up that PDF as the first hit for me. Regards, Malcolm From hpacheco at gmail.com Sat Dec 6 13:52:23 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Sat Dec 6 13:45:36 2008 Subject: [Haskell-cafe] ANNOUNCE: pointless-haskell 0.0.1 Message-ID: <7b92c2840812061052m3cafd25cq58e23ffb43c0cfe2@mail.gmail.com> Dear Haskelleers, Alcino Cunha and me are pleased to announce the release of the Pointless Haskell library in Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pointless-haskell Pointless Haskell is library for point-free programming with recursion patterns defined as hylomorphisms, inspired in ideas from the PolyP library. The re-implementation of the library using type functions (in opposition to classes with functional dependencies) enables a type-level view of data types as the fixed points of functors and provides a better experience to the users in terms of code sanity. The library also features the visualization of the intermediate data structure of hylomorphisms with GHood. I am giving birth to a website with some examples: http://haskell.di.uminho.pt/wiki/Pointless+Haskell Any feedback is welcome. Cheers, hugo -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081206/f09d811d/attachment.htm From gwern0 at gmail.com Sat Dec 6 14:04:49 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Dec 6 13:58:02 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: <4750D097-8031-4147-AD13-694DA15888FC@cs.york.ac.uk> References: <20081206073257.GB3970@flit> <4750D097-8031-4147-AD13-694DA15888FC@cs.york.ac.uk> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Sat, Dec 6, 2008 at 12:50 PM, Malcolm Wallace wrote: >> (This point, incidentally, raises a hobbyhorse of mine - Google didn't >> see the TMR haikus because they were in PDF. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkk6zNMACgkQvpDo5Pfl1oKVLwCfdVYevV4cfqTqBl9glikdMYaP 288AoIPA1IFuHjT6nQbpJDU71P2OeaJ7 =olrb -----END PGP SIGNATURE----- > > How odd. Googling for "haskell haiku TMR" brings up that PDF as the first > hit for me. > > Regards, > Malcolm Yes, but: 1) you could formulate that query only if you already knew TMR had haikus to look for. 2) The Google results are changing as we speak. I did another search for "Haskell haiku", and now I see, about 40 or 50 hits down, an email replying to a TMR ANN and praising the haikus. Further, I see this email thread, some mirrors, and the Haiku page on the wiki have popped up in the search results already, and in the top 20 or so. Further still: one high-up hit is an IRC log of #haskell, covering the haiku I found in lambdabot's @quotes database. I *know* that was not there when I was looking for haikus (before I wrote the page and started this thread). -- gwern From conrad at metadecks.org Sat Dec 6 14:37:51 2008 From: conrad at metadecks.org (Conrad Parker) Date: Sat Dec 6 14:31:02 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: References: <20081206073257.GB3970@flit> <4750D097-8031-4147-AD13-694DA15888FC@cs.york.ac.uk> Message-ID: 2008/12/7 Gwern Branwen : > On Sat, Dec 6, 2008 at 12:50 PM, Malcolm Wallace wrote: >>> (This point, incidentally, raises a hobbyhorse of mine - Google didn't >>> see the TMR haikus because they were in PDF. >> >> How odd. Googling for "haskell haiku TMR" brings up that PDF as the first >> hit for me. > > Yes, but: > 1) you could formulate that query only if you already knew TMR had > haikus to look for. > 2) The Google results are changing as we speak. I did another search > for "Haskell haiku", and now I see, about 40 or 50 hits down, an email > replying to a TMR ANN and praising the haikus. Further, I see this > email thread, some mirrors, and the Haiku page on the wiki have popped > up in the search results already, and in the top 20 or so. Further > still: one high-up hit is an IRC log of #haskell, covering the haiku I > found in lambdabot's @quotes database. I *know* that was not there > when I was looking for haikus (before I wrote the page and started > this thread). Snow fails a pure quest. unsafeGoogle reference is not transparent. K. -- http://twitter.com/conradparker From agocorona at gmail.com Sat Dec 6 14:49:11 2008 From: agocorona at gmail.com (Alberto G. Corona ) Date: Sat Dec 6 14:42:22 2008 Subject: [Haskell-cafe] Fwd: problems with hs-plugins load-eval In-Reply-To: References: Message-ID: I have a web server which load server extensions. these extensions eval-uate configuration files that contains code (user-editable workflow descriptions). The problem is that I need common definitions for the extensions and for the configurration files. This is not permitted by ha-plugins. The minimal code example are the files below. main loads eval.hs , that evaluate a expression. The common definitions are in Include.hs. The error is: *GHCi runtime linker: fatal error: I found a duplicate definition for symbol Include_sum1_srt whilst processing object file /home/magocoal/haskell/devel/votesWorkflow/src/unused/tests/Include.o This could be caused by: * Loading two different object files which export the same symbol * Specifying the same object file twice on the GHCi command line * An incorrect `package.conf' entry, causing some object to be loaded twice. GHCi cannot safely continue in this situation. Exiting now. Sorry. * ** Do you kno how to solve the problem while maintaining the functionality? -------Include.hs------- module Include where sum [x,y]= x+y ------Main.hs----- module Main where import Include import System.Plugins main= do s <-loadExec "eval.o" "mainc" print s loadExec:: String-> String->IO String loadExec file method = do mv <- load file ["."] [] method case mv of LoadSuccess mod v -> v :: IO String LoadFailure msg -> return $ concat msg ------------Eval.hs-------- module Eval(mainc) where import System.IO.Unsafe import System.Eval.Haskell mainc= do i <- unsafeEval_ "sum1 [1,2]" ["Include"] [] []["."] :: IO (Either [String] Int) return $ show i -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081206/4f919a00/attachment.htm From paul at cogito.org.uk Sat Dec 6 15:22:17 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Sat Dec 6 15:15:31 2008 Subject: [Haskell-cafe] Data.Map.fromListWith Message-ID: <493ADEF9.2050304@cogito.org.uk> I've just been looking at the Data.Map function "fromListWith". According to the docs, it has the type: * fromListWith* :: Ord k => (a -> a -> a) -> [(k, a)] -> Map k a I'd have thought that a better type would be * fromListWith* :: Ord k => (a -> b -> b) -> [(k, a)] -> Map k b This wouldn't break any existing code, but would allow things like "fromListWith (:)" to do the Right Thing. Would this be a sensible change (along with the other "with" functions in the module). Paul. From gwern0 at gmail.com Sat Dec 6 15:26:10 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Dec 6 15:19:23 2008 Subject: [Haskell-cafe] Threads not running under GHC 6.10? Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 So, the Hint library was recently updated and I was editing Mueval to run with (i386) 6.10, when I discovered that for some reason, DoS'ing expressions were succeeding in rendering my machine unusable. Eventually, I discovered that my watchdog thread didn't seem to be running. But with +RTS -N2 -RTS all my tests did pass! Here's a simple example of what I mean; the following is basically a very lightly adapted version of the actual Mueval code: - ---------------- import Control.Concurrent (forkIO, killThread, myThreadId, threadDelay, throwTo, yield, ThreadId) import System.Posix.Signals (sigXCPU, installHandler, Handler(CatchOnce)) import Control.OldException (Exception(ErrorCall)) main :: IO () main = do tid ThreadId -> IO () watchDog tout tid = do installHandler sigXCPU (CatchOnce $ throwTo tid $ ErrorCall "Time limit exceeded.") Nothing forkIO $ do threadDelay (tout * 100000) -- Time's up. It's a good day to die. throwTo tid (ErrorCall "Time limit exceeded") yield -- give the other thread a chance killThread tid -- Die now, srsly. error "Time expired" return () -- Never reached. Either we error out in -- watchDog, or the evaluation thread finishes. - -------------- Now, from the looks of it, this should always error out with "Time limit exceeded." And the threading is done via forkIO, so it shouldn't matter how it's compiled (be it threaded or no) or run; nor do we need to worry about optimizations, since x has no sensible value for any input - it's always bottom. But the results are very different: gwern@craft:31542~>=ghc -fforce-recomp -O0 example.hs && ./a.out ^C^C gwern@craft:31532~>=ghc -fforce-recomp -O0 -threaded example.hs && ./a.out ^C^C gwern@craft:31536~>=ghc -threaded -fforce-recomp -O0 -threaded example.hs && ./a.out +RTS -N1 -RTS [a minute later] ^C^C^C^C^C^C gwern@craft:31540~>=ghc -threaded -fforce-recomp -O0 -threaded example.hs && ./a.out +RTS -N2 -RTS a.out: Time limit exceeded gwern@craft:31543~>=ghc -fforce-recomp -O2 example.hs && ./a.out a.out: Time limit exceeded gwern@craft:31544~>=ghc -threaded -fforce-recomp -O2 example.hs && ./a.out a.out: Time limit exceeded gwern@craft:31545~>=ghc -threaded -fforce-recomp -O2 example.hs && ./a.out +RTS -N1 -RTS a.out: Time limit exceeded gwern@craft:31546~>=ghc -threaded -fforce-recomp -O2 example.hs && ./a.out +RTS -N2 -RTS a.out: Time limit exceeded So it seems that without optimizations, or without explicit/multiple OS threads, the watchdog thread never gets called! I'm not any sort of expert on parallelism or GHC, but this seems like a bad thing to me. One final note: I suspect there are further ways this can manifest. When compiled with -O2, example.hs terminates (as it should). But Mueval does in fact set -O2 as a ghc-option:, and yet I still found it looping. So, does anyone know whether this is an already known bug or whether it's something else? - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkk63+EACgkQvpDo5Pfl1oITZgCdG2p4VcB6m5IhfqzOT0fi5qrI VagAnRILZSxBzadSj2wlzoOWfBuwdbJo =X61b -----END PGP SIGNATURE----- -------------- next part -------------- A non-text attachment was scrubbed... Name: example.hs Type: text/x-haskell Size: 1196 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081206/f97811b4/example.bin From alexander.dunlap at gmail.com Sat Dec 6 15:35:11 2008 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat Dec 6 15:28:23 2008 Subject: [Haskell-cafe] Data.Map.fromListWith In-Reply-To: <493ADEF9.2050304@cogito.org.uk> References: <493ADEF9.2050304@cogito.org.uk> Message-ID: <57526e770812061235v787c0741ha0e633308e6fd83b@mail.gmail.com> On Sat, Dec 6, 2008 at 12:22 PM, Paul Johnson wrote: > I've just been looking at the Data.Map function "fromListWith". According > to the docs, it has the type: > > * fromListWith* :: Ord > > k => (a -> a -> a) -> [(k, a)] -> Map > > k a > > I'd have thought that a better type would be > > * fromListWith* :: Ord > > k => (a -> b -> b) -> [(k, a)] -> Map > > k b > > This wouldn't break any existing code, but would allow things like > "fromListWith (:)" to do the Right Thing. > > Would this be a sensible change (along with the other "with" functions in > the module). > > Paul. > Hi, I don't think that type makes sense. fromListWith takes a list of [(key,value)] and a combining function to combine the values when there are multiple pairs with the same key. Thus, a type of (a -> b -> b) for the combining function doesn't make sense because the values are all going to have the same type (i.e. they are all "a"s). We might consider (a -> a -> b), but this doesn't make sense either because then you have some values with type "a" (the ones that didn't need to be combined) and some with type "b" (the ones that were combined). (a -> a -> a) is really the only type that works. I don't think fromListWith (:) makes sense either. (:) :: a -> [a] -> [a], so you would end up with some values of the map as individual items and others as lists of items. All of the values need to have the same type. Regards, Alex From paul at cogito.org.uk Sat Dec 6 16:07:51 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Sat Dec 6 16:01:13 2008 Subject: [Haskell-cafe] Data.Map.fromListWith In-Reply-To: <57526e770812061235v787c0741ha0e633308e6fd83b@mail.gmail.com> References: <493ADEF9.2050304@cogito.org.uk> <57526e770812061235v787c0741ha0e633308e6fd83b@mail.gmail.com> Message-ID: <493AE9A7.7030900@cogito.org.uk> Alexander Dunlap wrote: > On Sat, Dec 6, 2008 at 12:22 PM, Paul Johnson wrote: > >> I've just been looking at the Data.Map function "fromListWith". According >> to the docs, it has the type: >> >> * fromListWith* :: Ord >> >> k => (a -> a -> a) -> [(k, a)] -> Map >> >> k a >> >> I'd have thought that a better type would be >> >> * fromListWith* :: Ord >> >> k => (a -> b -> b) -> [(k, a)] -> Map >> >> k b >> >> This wouldn't break any existing code, but would allow things like >> "fromListWith (:)" to do the Right Thing. >> >> Would this be a sensible change (along with the other "with" functions in >> the module). >> >> Paul. >> >> > > Hi, > > I don't think that type makes sense. fromListWith takes a list of > [(key,value)] and a combining function to combine the values when > there are multiple pairs with the same key. Ahh yes. I was thinking that the job of fromListWith was analogous to foldr, but carrying out the fold on a per-key basis. However I see now that it is more like foldr1 than foldr because foldr needs a zero value. So we could have fromListWithZero :: Ord k => (a -> b -> b) -> b -> [(k, a)] -> Map k b fromListWithZero combiner zero pairs = ... The first time a key is seen the combining function is called with "zero" as its second argument. E.g. fromListWithZero (:) [] xs Or is that too much trouble? Accumulating a collection of lists is the most obvious use of this function, and you can do that already (albeit rather clunkily) with fromListWith (++) $ map (\(k,v) -> (k, [v]) $ xs The only time that fromListWithZero would be especially useful is when you want the fold to be eager. Paul. From byorgey at seas.upenn.edu Sat Dec 6 16:27:18 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Dec 6 16:20:28 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 96 - December 6, 2008 Message-ID: <20081206212718.GA30778@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20081206 Issue 96 - December 06, 2008 --------------------------------------------------------------------------- Welcome to issue 96 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements Haskell haikus. Gwern Branwen [2]announced that he has collected all known haikus about Haskell and put them on a [3]wiki page. Add more! Platforms that GHC supports. Simon Peyton-Jones [4]linked to a [5]new page clearly articulating what platforms GHC supports, and what platforms its maintainers would like it to support. If you're interested and willing to help sponsor a "Tier 2" platform, let them know! Using Data Parallel Haskell. Manuel Chakravarty [6]announced a new [7]wiki page with documentation for Data Parallel Haskell. DrHylo 0.0.1. Hugo Pacheco [8]announced the [9]release of [10]DrHylo, a tool for deriving hylomorphisms from a restricted Haskell syntax. It is based on the algorithm first presented in the paper Deriving Structural Hylomorphisms From Recursive Definitions at ICFP'96 by Hu, Iwasaki, and Takeichi. The generated code can be run with [11]Pointless Haskell, allowing the visualization of the recursion trees of Haskell functions. pointless-haskell 0.0.1. Hugo Pacheco [12]announced the [13]release of [14]Pointless Haskell, a library for point-free programming with recursion patterns defined as hylomorphisms, inspired in ideas from the PolyP library. The re-implementation of the library using type functions (in opposition to classes with functional dependencies) enables a type-level view of data types as the fixed points of functors and provides a better experience to the users in terms of code sanity. The library also features the visualization of the intermediate data structure of hylomorphisms with GHood. Projects that depend on the vty package?. Corey O'Connor [15]asked whether there are any other projects that depend on the [16]vty package. If so, let him know! The package also has a new [17]trac and wiki. haskell-src-exts 0.4.4. Niklas Broberg [18]announced the release of [19]haskell-src-exts 0.4.4, which adds support for pragmas. ChristmasTree 0.1. S. Doaitse Swierstra [20]announced the release of the [21]ChristmasTree package, which stands for "Changing Haskell's Read Implementation Such That by Manipulating Abstract Syntax Trees it Reads Expressions Efficiently". TTTAS. S. Doaitse Swierstra [22]announced the release of [23]TTTAS, a library for typed transformations of typed abstract syntax. GHood. Hugo Pacheco [24]announced that GHood, a graphical backend for the lightweight Hood Haskell debugger, has now been [25]released as a Cabal package. Discussion Animated line art. Andrew Coppin [26]asked for ideas on writing Haskell to generate some animations. Jobs Scala job in Boston writing quantitative finance software. Paul Chiusano [27]announced that [28]ClariFI is looking to hire developers with a strong background in functional programming to do a mixture of Scala and Java programming. ClariFI is a small company (about 15 developers) that specializes in software for quantitative investment management. This position is for the Boston office. If you're interested, send him an email. Blog noise [29]Haskell news from the [30]blogosphere. * Bryan O'Sullivan: [31]Functional programmers on Twitter. * Conal Elliott: [32]Sequences, segments, and signals. * >>> Gianfranco Alongi: [33]QuickCheck(ing) the code i C. * Edward Kmett: [34]The Pointed-Set Comonad. * Twan van Laarhoven: [35]Knight in n, part 3: rings. * "The GHC Team": [36]Explicit Stack Traces. * Real-World Haskell: [37]The Real World Haskell Book Club. * Real-World Haskell: [38]Real World Haskell: Now in Brazil. * >>> Matt Hellige: [39]Pointless fun. * Chung-chieh Shan: [40]The pointed-set monad. * Holumbus: [41]Status Update. * Paul R Brown: [42].editrc Tidbit for ghci. * Roman Cheplyaka: [43]DPH docs and project status. * David Sankel: [44]Introducing Reactive: Behaviors. * Manuel M T Chakravarty: [45]How to use Data Parallel Haskell.. * Conal Elliott: [46]Prettier functions for wrapping and wrapping. * Twan van Laarhoven: [47]Knight in n, part 2: combinatorics. * Yi: [48]Prototypes: Encoding OO-style inheritance in Haskell. * "Osfameron": [49]Functional Pe(a)rls v2 (now with Monads!) at the London Perl Workshop 2008. * Conal Elliott: [50]Sequences, streams, and segments. * Conal Elliott: [51]Early inspirations and new directions in functional reactive programming. * Clemens Fruhwirth: [52]XMonad GridSelect. About the Haskell Weekly News New editions are posted to [53]the Haskell mailing list as well as to [54]the Haskell Sequence and [55]Planet Haskell. [56]RSS is also available, and headlines appear on [57]haskell.org. To help create new editions of this newsletter, please see the information on [58]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [59]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://www.haskell.org//pipermail/haskell-cafe/2008-December/051529.html 3. http://haskell.org/haskellwiki/Haiku 4. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/15958 5. http://hackage.haskell.org/trac/ghc/wiki/Platforms 6. http://www.haskell.org//pipermail/glasgow-haskell-users/2008-December/016271.html 7. http://haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 8. http://article.gmane.org/gmane.comp.lang.haskell.general/16668 9. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/DrHylo 10. http://haskell.di.uminho.pt/wiki/DrHylo 11. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pointless-haskell 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/48598 13. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pointless-haskell 14. http://haskell.di.uminho.pt/wiki/Pointless+Haskell 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/48471 16. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vty 17. http://trac.haskell.org/vty/ 18. http://www.haskell.org//pipermail/haskell-cafe/2008-December/051444.html 19. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts-0.4.4 20. http://www.haskell.org//pipermail/haskell/2008-December/020847.html 21. http://en.wikipedia.org/wiki/Sinterklaas 22. http://www.haskell.org//pipermail/haskell/2008-December/020848.html 23. http://www.cs.uu.nl/wiki/bin/view/Center/TTTAS 24. http://www.haskell.org//pipermail/haskell/2008-December/020849.html 25. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GHood-0.0.2 26. http://www.haskell.org//pipermail/haskell-cafe/2008-December/051451.html 27. http://www.haskell.org//pipermail/haskell-cafe/2008-December/051295.html 28. http://clarifi.com/ 29. http://planet.haskell.org/ 30. http://haskell.org/haskellwiki/Blog_articles 31. http://www.serpentine.com/blog/2008/12/05/functional-programmers-on-twitter/ 32. http://conal.net/blog/posts/sequences-segments-and-signals/ 33. http://writert.blogspot.com/2008/12/quickchecking-code-i-c.html 34. http://comonad.com/reader/2008/the-pointed-set-comonad/ 35. http://twan.home.fmf.nl/blog/haskell/Knight3.details 36. http://ghcmutterings.wordpress.com/2008/12/04/explicit-stack-traces/ 37. http://www.realworldhaskell.org/blog/2008/12/03/the-real-world-haskell-book-club/ 38. http://www.realworldhaskell.org/blog/2008/12/03/real-world-haskell-now-in-brazil/ 39. http://matt.immute.net/content/pointless-fun 40. http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Pointed_set/ 41. http://holumbus.fh-wedel.de/blog/?p=16 42. http://mult.ifario.us/p/editrc-tidbit-for-ghci 43. http://physics-dph.blogspot.com/2008/12/dph-docs-and-project-status.html 44. http://netsuperbrain.com/blog/posts/introducing-reactive-behaviors/ 45. http://justtesting.org/post/62610924 46. http://conal.net/blog/posts/prettier-functions-for-wrapping-and-wrapping/ 47. http://twan.home.fmf.nl/blog/haskell/Knight2.details 48. http://yi-editor.blogspot.com/2008/12/prototypes-encoding-oo-style.html 49. http://greenokapi.net/blog/2008/12/01/functional-pearls-v2-now-with-monads-at-the-london-perl-workshop-2008/ 50. http://conal.net/blog/posts/sequences-streams-and-segments/ 51. http://conal.net/blog/posts/early-inspirations-and-new-directions-in-functional-reactive-programming/ 52. http://blog.clemens.endorphin.org/2008/11/xmonad-gridselect.html 53. http://www.haskell.org/mailman/listinfo/haskell 54. http://sequence.complete.org/ 55. http://planet.haskell.org/ 56. http://sequence.complete.org/node/feed 57. http://haskell.org/ 58. http://haskell.org/haskellwiki/HWN 59. http://code.haskell.org/~byorgey/code/hwn/ From martijn at van.steenbergen.nl Sat Dec 6 16:32:16 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Dec 6 16:25:27 2008 Subject: [Haskell-cafe] Can't cabal install readline In-Reply-To: <6d74b0d20812051408u18d8df80yd5ea066a770557ca@mail.gmail.com> References: <493998CF.60904@van.steenbergen.nl> <6d74b0d20812051408u18d8df80yd5ea066a770557ca@mail.gmail.com> Message-ID: <493AEF60.5020504@van.steenbergen.nl> Judah Jacobson wrote: > The following instructions should re-enable Ctrl-R: > > http://mult.ifario.us/p/editrc-tidbit-for-ghci Yes, that worked perfectly, thanks! > The above happens because GHC is using the OS X default installation > of libreadline.a which is actually a link to libedit that doesn't > implement the full readline API. > > If you already have the MacPorts readline, you just need to tell cabal > where it is, with (for example) > > cabal install readline --extra-include-dirs=/opt/local/include > --extra-lib-dirs=/opt/local/lib This didn't immediately fix the problem. But I found out readline was installed but deactivated, which explained why there was nothing readline-related in /opt/local/lib. Reactivating fixed it; I didn't even need to give cabal install any extra hints. Thanks for the help. :-) Martijn. From simon at joyful.com Sat Dec 6 16:59:06 2008 From: simon at joyful.com (Simon Michael) Date: Sat Dec 6 16:52:27 2008 Subject: [Haskell-cafe] latest Hood ? Message-ID: Hugo Pacheco wrote: > The library also features the visualization of the intermediate data > structure of hylomorphisms with GHood. I hadn't come across GHood and Hood before, and they look quite a useful addition to the toolbox. http://www.haskell.org/hood says "The current released version of HOOD is the July 2000 release, but there is also a patch to all HOOD to work with GHC 5.00.". The Observe.lhs there doesn't immediately work with current GHC. Has anyone got an updated version, or is this available in some more recent library or package ? Or, I may have misunderstood, and Debug.Trace may do everything that Hood did. Still, a working Hood would be useful to get the nice visualisations of GHood. Thanks - Simon From skynare at gmail.com Sat Dec 6 17:05:12 2008 From: skynare at gmail.com (sam lee) Date: Sat Dec 6 16:58:23 2008 Subject: [Haskell-cafe] SDL program under MinGW Message-ID: <4e7aa0f80812061405g4fa493f4p6149509e935c56c1@mail.gmail.com> Hi. I am using Windows Vista. I installed the following: - ghc 6.8.3 (using official Windows binary installer) - MinGW (from http://nuwen.net/mingw.html) - SDL binding (from http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL) I am trying to compile the following program: module Main where import qualified Graphics.UI.SDL as SDL main = do SDL.init [SDL.InitEverything] SDL.quit I get the following error: C:\Users\client\code\sandbox>ghc --make Example.hs Linking Example.exe ... C:\MinGW\lib/libSDLmain.a(SDL_win32_main.o)(.text+0x409):SDL_win32_main.c: undefined reference to `SDL_main' According to SDL faq (http://www.libsdl.org/faq.php?action=listentries&category=4#48) I should use "int main(int argc, char *argv[])", not "int main()" nor "WinMain()". Can anyone compile the above snippet on windows machine? I am using SDL library that is shipped with MinGW distribution that I'm using. I also recompiled SDL haskell binding with official SDL windows binary (http://www.libsdl.org/release/SDL-devel-1.2.13-mingw32.tar.gz). But I get the same undefined reference to SDL_main linker error. Do I need to have specific main IO action so that SDL would work in Haskell? Thank you. Sam. From ryani.spam at gmail.com Sat Dec 6 17:19:12 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Dec 6 17:12:26 2008 Subject: [Haskell-cafe] SDL program under MinGW In-Reply-To: <4e7aa0f80812061405g4fa493f4p6149509e935c56c1@mail.gmail.com> References: <4e7aa0f80812061405g4fa493f4p6149509e935c56c1@mail.gmail.com> Message-ID: <2f9b2d30812061419r373fd811n6bb205653754ec8f@mail.gmail.com> >From the link you provided (http://www.libsdl.org/faq.php?action=listentries&category=4#48) > Q: I get "Undefined reference to 'SDL_main'" ... > A: Make sure that you are declaring main() as: > > #include "SDL.h" > > int main(int argc, char *argv[]) In particular notice that they want you to include SDL.h. I suspect they are doing something scary like > #define main(ac, av) SDL_Main(ac, av, maybe some other args) The problem is that the library itself is defining WinMain, so you've got a fight between the Haskell compiler (which wants to define the entry point for your program to start up the runtime), and the SDL library (which is trying to be "helpful" and failing). I think the binding needs to not include SDLMain and instead do the initialization itself; see the rest of that FAQ question. In fact, the "MACOSX" readme file in the Haskell SDL binding talks about exactly this problem. -- ryan On Sat, Dec 6, 2008 at 2:05 PM, sam lee wrote: > Hi. > > I am using Windows Vista. > I installed the following: > > - ghc 6.8.3 (using official Windows binary installer) > - MinGW (from http://nuwen.net/mingw.html) > - SDL binding (from > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL) > > I am trying to compile the following program: > > module Main where > > import qualified Graphics.UI.SDL as SDL > > main = do > SDL.init [SDL.InitEverything] > SDL.quit > > I get the following error: > > C:\Users\client\code\sandbox>ghc --make Example.hs > Linking Example.exe ... > C:\MinGW\lib/libSDLmain.a(SDL_win32_main.o)(.text+0x409):SDL_win32_main.c: > undefined reference to `SDL_main' > > According to SDL faq > (http://www.libsdl.org/faq.php?action=listentries&category=4#48) I > should use "int main(int argc, char *argv[])", not "int main()" nor > "WinMain()". > > Can anyone compile the above snippet on windows machine? > I am using SDL library that is shipped with MinGW distribution that I'm using. > I also recompiled SDL haskell binding with official SDL windows binary > (http://www.libsdl.org/release/SDL-devel-1.2.13-mingw32.tar.gz). But I > get the same undefined reference to SDL_main linker error. > > Do I need to have specific main IO action so that SDL would work in Haskell? > > Thank you. > Sam. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From simon at joyful.com Sat Dec 6 17:21:23 2008 From: simon at joyful.com (Simon Michael) Date: Sat Dec 6 17:14:44 2008 Subject: [Haskell-cafe] Re: Projects that depend on the vty package? In-Reply-To: References: Message-ID: Hi Corey.. I noticed this thread via Haskell Weekly News. Corey O'Connor wrote: > For further development of the vty package I'm really only paying > attention to the requirements that fall out of the Yi project. Are > there any other projects that depend on the vty package? Why yes! I just used it within the hledger project. I found it easier to get started with the (h/nano)curses libs. From your cursor-moving example I started tweaking and soon had a working ui. It works well here and I'm hoping it will be pretty robust across platforms. More top of the head feedback: I liked the level of abstraction, it seems to handle a lot of routine stuff for me. I liked to hear that it avoids flicker that (apparently) curses suffers from. I expected renderBS to convert a multiline string into an Image of height > 1. It might be nice if the <-> and <|> combinators were more forgiving about mismatching dimensions, I get unexpected failures from them. After a failure like this my program quits but the terminal is not properly reset until I run "reset" manually. I believe vty supports only whole-screen updates, and you could write more performant uis by careful use of *curses ? My experiment is quick enough for regular use on my macbook, but I can only move the cursor so fast and when I highlight the whole line that it's on there is noticeable double-display while I move. I haven't tried profiling yet. I'd welcome any tips on how to write a cross-platform TUI that updates instantly! So thank you and Stefan O'Rear very much indeed! -Simon From simon at joyful.com Sat Dec 6 17:23:09 2008 From: simon at joyful.com (Simon Michael) Date: Sat Dec 6 17:18:16 2008 Subject: [Haskell-cafe] Re: Projects that depend on the vty package? In-Reply-To: References: Message-ID: > I found it easier to get started with the (h/nano)curses libs. From your I meant: easier THAN the curses libs. From ml at niaow.com Sat Dec 6 17:32:11 2008 From: ml at niaow.com (Laurent Giroud) Date: Sat Dec 6 17:33:48 2008 Subject: [Haskell-cafe] Building/installing haskelldb and friends with ghc 6.10.1 Message-ID: <709219BA-DF78-49CA-8C25-314A7017D43F@niaow.com> Hi everyone, I have been trying to install haskelldb in the last few days and encountered a number of hurdles which raised a few questions and for which I'd appreciate some insight and advice. Note that I am posting here because they are not specifically haskelldb related. I am using Cabal to install haskelldb, haskelldb-hsql, haskelldb-hsql- mysql (and others) and discovered that the packages available on hackage do not build properly with ghc 6.10.1. The typical error being of the following kind: Could not find module `System.Time': it is a member of package old-time-1.0.0.1, which is hidden These ones are relatively easy to fix by finding the locally cached .tar.gz and modifying the .cabal file to include the corresponding packages (there were several of them which were discovered in successive attempts). But I finally stumbled on hsql-mysql due to it apparently not being actively maintained anymore (this seemingly simple conclusion actually required quite a lot of research). I read on haskell-cafe that Frederik Eaton had been apparently fixing these problems but could find nowhere a version exhibiting the will to compile gracefully, a darcs repository at http://code.haskell.org/ HSQL/ apparently containing patches from him also proved reluctant to build, although for different reasons. I wasn't courageous enough to pursue and try to fix them at that point of the adventure. Other searches in haskell cafe lead me to people advising to use HDBC instead, after which I contemplated suicide for a few seconds before coming back to my senses and cabal-installing haskelldb-hdbc which quickly led me to error messages of the exact same kind mentioned above. Strangely enough, hdbc 1.1.5 itself installs quite fine using Cabal, however, haskell-hdbc insists on depending on version 1.0.1. I haven't been able so far to find what configuration file to modify in order for it to try to build with the latest Cabalized version (I admit I didn't search much). I then discovered this page http://www.haskell.org/haskellwiki/Upgrading_packages which hints that some of the existing packages in Hackage need "a bit" of work to be usable with ghc 6.10.1 as well as ghc 6.8.x apparently. HSQL and haskelldb-HDBC seem indeed to be in the list of packages which would require some effort in order to be usable with the latest ghc versions (can't remember where I read that though). Pursuing any further would seem to require to delve deeper in the intricacies of the Cabal system and fix either HSQL or HaskellDB-HDBC. Since I really want to use HaskellDB I'll probably try these avenues, but I would appreciate comments at this point from persons knowledgeable in the evocated areas: Are the databases interface for haskelldb still officially maintained and where is this information available ? Is the information that this and that package are compatible (or not) with ghc 6.8.x or 6.10.1 available somewhere without compiling first hand the packages ? It would be immensely valuable to the haskell newcomer to have the incompatible packages signaled on http://hackage.haskell.org/packages/archive/pkg-list.html for example. What would you recommend at this point : fix hsql, or haskelldb-hdbc so it uses 1.1.5 instead of 1.1, try an alternative to haskelldb (are there any ?) ? Thanks in advance for your comments and advices. Best regards, Laurent -- Laurent Giroud ml@niaow.com From hpacheco at gmail.com Sat Dec 6 17:55:37 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Sat Dec 6 17:48:48 2008 Subject: [Haskell-cafe] latest Hood ? In-Reply-To: References: Message-ID: <7b92c2840812061455m6493660dr95bd374a90b0144e@mail.gmail.com> In fact, Hood is just the module Debug.Observe.GHood just extends Debug.Observe with some more constructs to handle visualizations, for instance, it adds a temporal dimension to observations. This means that you can use the GHood cabal package nonetheless, and be able to use both GHood graphically or textually (the features of Hood). GHood gives you both. Whenever you use runO, it will call the Java applet with the graphical visualization but still output the textual trace from Hood. As an example, just import Debug.Observe (the GHood one), run ghci and type > runO $ print $ (length . observe "List Int" .concat) [[1,2],[3,4]] I suggest you install the cabal package and try the sample module form the Hood homepage: http://www.haskell.org/hood/downloads/Main.hs Feel free to ask for anything. Cheers, hugo On Sat, Dec 6, 2008 at 9:59 PM, Simon Michael wrote: > Hugo Pacheco wrote: > > The library also features the visualization of the intermediate data > > structure of hylomorphisms with GHood. > > I hadn't come across GHood and Hood before, and they look quite a useful > addition to the toolbox. > > http://www.haskell.org/hood says "The current released version of HOOD is > the July 2000 release, but there is also a patch to all HOOD to work with > GHC 5.00.". The Observe.lhs there doesn't immediately work with current GHC. > Has anyone got an updated version, or is this available in some more recent > library or package ? > > Or, I may have misunderstood, and Debug.Trace may do everything that Hood > did. Still, a working Hood would be useful to get the nice visualisations of > GHood. > > Thanks - Simon > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081206/71466461/attachment.htm From simon at joyful.com Sat Dec 6 18:13:26 2008 From: simon at joyful.com (Simon Michael) Date: Sat Dec 6 18:06:46 2008 Subject: [Haskell-cafe] Re: latest Hood ? In-Reply-To: <7b92c2840812061455m6493660dr95bd374a90b0144e@mail.gmail.com> References: <7b92c2840812061455m6493660dr95bd374a90b0144e@mail.gmail.com> Message-ID: Hugo, I thought "this Hood stuff is so old, there's no point checking hackage". Silly me! I did cabal update; cabal install GHood on this mac and tried your example: > As an example, just import Debug.Observe (the GHood one), run ghci and type > >> runO $ print $ (length . observe "List Int" .concat) [[1,2],[3,4]] and it fired up the graphical Java applet without any further setup. Very nice! I don't yet know what a hylomorphism is and thought your pointless-haskell package might be one of those semi-joke projects, but now I wonder if it's something that I'll need in order to use (G)Hood with real-world code. I guess I'll find out. Thank you! From coreyoconnor at gmail.com Sat Dec 6 18:14:55 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Sat Dec 6 18:08:05 2008 Subject: [Haskell-cafe] Re: Projects that depend on the vty package? In-Reply-To: References: Message-ID: On Sat, Dec 6, 2008 at 2:21 PM, Simon Michael wrote: > Hi Corey.. I noticed this thread via Haskell Weekly News. > > Corey O'Connor wrote: >> >> For further development of the vty package I'm really only paying >> attention to the requirements that fall out of the Yi project. Are >> there any other projects that depend on the vty package? > > Why yes! I just used it within the hledger project. Thanks for the reply! I will try out hledger and verify (As much as I can) that I don't introduce regressions with any changes I make. I'm going to add the issues you outline below to VTY's issue tracker (http://trac.haskell.org/vty/) If you think of anything else feel free to file an issue there. Though reports directly sent to me or added to the Yi issue tracker will work as well. > I expected renderBS to convert a multiline string into an Image of height > > 1. Agreed. http://trac.haskell.org/vty/ticket/8 > It might be nice if the <-> and <|> combinators were more forgiving about > mismatching dimensions, I get unexpected failures from them. After a failure > like this my program quits but the terminal is not properly reset until I > run "reset" manually. Oh definitely. This bit me a few times when adding GUI tabs to Yi. I'd much prefer not to have to worry about matching dimensions. http://trac.haskell.org/vty/ticket/9 > I believe vty supports only whole-screen updates, and you could write more > performant uis by careful use of *curses ? My experiment is quick enough for > regular use on my macbook, but I can only move the cursor so fast and when I > highlight the whole line that it's on there is noticeable double-display > while I move. I haven't tried profiling yet. I'd welcome any tips on how to > write a cross-platform TUI that updates instantly! Some optimization is attempted on update. I haven't looked into the details of how this is done yet. There is an issue with the current process with regards to multi-byte characters. After I investigate that issue I should know more. Cheers, Corey O'Connor From dokondr at gmail.com Sat Dec 6 18:39:31 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Sat Dec 6 18:32:43 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <200812060032.21681.daniel.is.fischer@web.de> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> <200812060032.21681.daniel.is.fischer@web.de> Message-ID: <53396d9e0812061539k1dd299bt456420750bd84e92@mail.gmail.com> Daniel, thanks! I used your advice, it works, yet some more questions, if you don't mind :) So: {-- Why showList returns a function of type: type ShowS = String -> String In fact showList returns a function which already contains all values from list converted to a single string. Why return function instead of a ready to use string? --} data ShipInfo = Ship { name :: String, kind :: String, cannons :: Int } s1 = Ship {name ="HMS Fly", kind = "sloop", cannons=16} s2 = Ship {name ="HMS Surprise", kind = "frigate", cannons=42} fleet = [s1,s2] instance Show ShipInfo where show x = "Ship "++ show (name x) ++" is a " ++ show(kind x) ++ " with " ++ show (cannons x) ++ " cannons " showList xs = showString (foldr (\x y -> x ++ " <*> "++y) [] (map show xs)) {-- Now when I type 'fleet' I get: *ShowFleet> fleet Ship "HMS Fly" is a "sloop" with 16 cannons <*> Ship "HMS Surprise" is a "frigate" with 42 cannons <*> *ShowFleet> On the other hand evaluating t2 : --} t2 xs = foldr (\x y -> x ++ " <*> "++y) [] (map show xs) {-- provides: *ShowFleet> t2 fleet "Ship \"HMS Fly\" is a \"sloop\" with 16 cannons <*> Ship \"HMS Surprise\" is a \"frigate\" with 42 cannons <*> " *ShowFleet> More questions: 1)Where characters \" come from in this case? 2)How showList function 'removes' characters \" from the output? What magic goes behind the scenes here? --} Thanks! Dmitri On 12/6/08, Daniel Fischer wrote: > Am Samstag, 6. Dezember 2008 00:13 schrieb Dmitri O.Kondratiev: >> >> Thanks everybody for your help! >> I tried to implement showList, but get the same error: >> >> {-- >> -- from Prelude: >> type *ShowS* = >> String>ring>-> >> String>ring> *showList* :: [a] -> >> ShowS>wS> --} >> >> myShows::ShowS >> myShows s = s ++ "\n" >> >> data ShipInfo = Ship { >> name :: String, >> kind :: String, >> canons :: Int >> } deriving Show > > No, if you derive the Show instance for ShipInfo, it automatically > implements > the standard showList, too. You have to do it yourself: > > data ShipInfo = Ship { > name :: String, > kind :: String, > canons :: Int > } > > instance Show ShipInfo where > showsPrec p (Ship name kind canons) = ... > showList xs = showString (unlines $ map show xs) > > or whatever you want for showList. > However, somebody said it before, the Show instance should not be used for > pretty-printing. > > >> >> -- I get this error again: >> instance (Show [ShipInfo]) where >> showList [] = myShows [] >> showList (x:xs) = myShows "x" ++ showList xs >> >> Illegal instance declaration for `Show [ShipInfo]' >> (The instance type must be of form (T a b c) >> where T is not a synonym, and a,b,c are distinct type variables) >> In the instance declaration for `Show [ShipInfo]' >> Failed, modules loaded: none. >> >> -- What am I doing wrong? >> Thanks! > > -- Haste makes waste - Lose not a moment! Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr From hpacheco at gmail.com Sat Dec 6 18:46:26 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Sat Dec 6 18:39:37 2008 Subject: [Haskell-cafe] Re: latest Hood ? In-Reply-To: References: <7b92c2840812061455m6493660dr95bd374a90b0144e@mail.gmail.com> Message-ID: <7b92c2840812061546j4db1ba0ei1757a10d3f64cb80@mail.gmail.com> On Sat, Dec 6, 2008 at 11:13 PM, Simon Michael wrote: > Hugo, > > I thought "this Hood stuff is so old, there's no point checking hackage". > Silly me! I did cabal update; cabal install GHood on this mac and tried your > example: > > As an example, just import Debug.Observe (the GHood one), run ghci and >> type >> >> runO $ print $ (length . observe "List Int" .concat) [[1,2],[3,4]] >>> >> > and it fired up the graphical Java applet without any further setup. Very > nice! > > I don't yet know what a hylomorphism is and thought your pointless-haskell > package might be one of those semi-joke projects, but now I wonder if it's > something that I'll need in order to use (G)Hood with real-world code. > It shouldn't be. Pointless Haskell is for point-free programming and it is quite arguable if that is real-world Haskell. The main advantage is that it is easier to reason about programs, that is why it recursion patterns such as hylomorphisms are fun. But by no means you need it for using (G)Hood in your applications. > > I guess I'll find out. Thank you! You can always run some of the examples from the Pointless Haskell library or just have a quick look at http://haskell.di.uminho.pt/wiki/Pointless+Haskell/Examples. Cheers, hugo > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081206/f739815e/attachment.htm From skynare at gmail.com Sat Dec 6 19:24:00 2008 From: skynare at gmail.com (sam lee) Date: Sat Dec 6 19:17:12 2008 Subject: [Haskell-cafe] SDL program under MinGW In-Reply-To: <2f9b2d30812061419r373fd811n6bb205653754ec8f@mail.gmail.com> References: <4e7aa0f80812061405g4fa493f4p6149509e935c56c1@mail.gmail.com> <2f9b2d30812061419r373fd811n6bb205653754ec8f@mail.gmail.com> Message-ID: <4e7aa0f80812061624j3801db07ye40d43f1031636@mail.gmail.com> I can compile http://darcs.haskell.org/~lemmih/hsSDL/hssdl/Examples/MacOSX/Test.hs But I can't find the "small Cabal file" and c_main.c . Does anyone have those files? I want to try if Test.hs links well on windows platform. > I think the binding needs to not include SDLMain and instead do the initialization itself; see the rest of that FAQ question. I can't grep for SDLMain in the binding. How should I modify the binding code to use WinMain + proper initialization? Thanks. Sam. On Sat, Dec 6, 2008 at 5:19 PM, Ryan Ingram wrote: > From the link you provided > (http://www.libsdl.org/faq.php?action=listentries&category=4#48) > >> Q: I get "Undefined reference to 'SDL_main'" ... >> A: Make sure that you are declaring main() as: >> >> #include "SDL.h" >> >> int main(int argc, char *argv[]) > > In particular notice that they want you to include SDL.h. I suspect > they are doing something scary like > >> #define main(ac, av) SDL_Main(ac, av, maybe some other args) > > The problem is that the library itself is defining WinMain, so you've > got a fight between the Haskell compiler (which wants to define the > entry point for your program to start up the runtime), and the SDL > library (which is trying to be "helpful" and failing). > > I think the binding needs to not include SDLMain and instead do the > initialization itself; see the rest of that FAQ question. > > In fact, the "MACOSX" readme file in the Haskell SDL binding talks > about exactly this problem. > > -- ryan > > On Sat, Dec 6, 2008 at 2:05 PM, sam lee wrote: >> Hi. >> >> I am using Windows Vista. >> I installed the following: >> >> - ghc 6.8.3 (using official Windows binary installer) >> - MinGW (from http://nuwen.net/mingw.html) >> - SDL binding (from >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL) >> >> I am trying to compile the following program: >> >> module Main where >> >> import qualified Graphics.UI.SDL as SDL >> >> main = do >> SDL.init [SDL.InitEverything] >> SDL.quit >> >> I get the following error: >> >> C:\Users\client\code\sandbox>ghc --make Example.hs >> Linking Example.exe ... >> C:\MinGW\lib/libSDLmain.a(SDL_win32_main.o)(.text+0x409):SDL_win32_main.c: >> undefined reference to `SDL_main' >> >> According to SDL faq >> (http://www.libsdl.org/faq.php?action=listentries&category=4#48) I >> should use "int main(int argc, char *argv[])", not "int main()" nor >> "WinMain()". >> >> Can anyone compile the above snippet on windows machine? >> I am using SDL library that is shipped with MinGW distribution that I'm using. >> I also recompiled SDL haskell binding with official SDL windows binary >> (http://www.libsdl.org/release/SDL-devel-1.2.13-mingw32.tar.gz). But I >> get the same undefined reference to SDL_main linker error. >> >> Do I need to have specific main IO action so that SDL would work in Haskell? >> >> Thank you. >> Sam. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From allbery at ece.cmu.edu Sat Dec 6 20:14:02 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Dec 6 20:07:22 2008 Subject: [Haskell-cafe] Re: latest Hood ? In-Reply-To: References: <7b92c2840812061455m6493660dr95bd374a90b0144e@mail.gmail.com> Message-ID: <44F5C951-1EC1-449B-B08C-540F17C19524@ece.cmu.edu> On 2008 Dec 6, at 18:13, Simon Michael wrote: > I don't yet know what a hylomorphism is and thought your pointless- > haskell package might be one of those semi-joke projects, but now I > wonder if it's something that I'll need in order to use (G)Hood with > real-world code. Not a joke. People who reason about programs (more of a mathematical discipline than a programming one) like to use the tools of category theory (a generalization of set theory). At the category-theoretical level, the important parts of Haskell are functors (functions that operate on functions; they perform transformations on types) and types (equivalent to sets); values don't actually appear anywhere, they stay hidden inside types. So to use those tools, you need to remove the values; values are also known as "points", hence "point-free" or "point-less" (a bit of a joke, that) programming. Morphisms (catamorphism, hylomorphism, etc.) are category-theoretical transformations, which are represented in Haskell as functors. Many common functional "patterns" are derived from these reflections of category theory transformations in the language. -- 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 zooko at zooko.com Sat Dec 6 20:31:39 2008 From: zooko at zooko.com (zooko) Date: Sat Dec 6 20:24:53 2008 Subject: [Haskell-cafe] Trouble installing ghc-6.10.1 on linux In-Reply-To: <20081111222619.GA31442@matrix.chaos.earth.li> References: <6205bd290811100505o4be9248pfe0b70a106692ec2@mail.gmail.com> <20081111222619.GA31442@matrix.chaos.earth.li> Message-ID: <20876884.post@talk.nabble.com> Hi there! I have the same problem. The machine is running Ubuntu 7.04 x86. ghc is v6.6 as provided by Ubuntu -- the Ubuntu version number is 6.6-3. The complete cabal-bin command-line, as executed by "make", is: /home/zooko/playground/ghc/ghc-6.10.1/libraries/cabal-bin /usr/bin/ghc /home/zooko/playground/ghc/ghc-6.10.1/libraries/bootstrapping.conf configure --distpref dist-stage2 --flags=-stage1 --flags=ncg --flags=ghci --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE --enable-library-profiling --with-compiler=/home/zooko/playground/ghc/ghc-6.10.1/ghc/stage1-inplace/ghc --with-hc-pkg=/home/zooko/playground/ghc/ghc-6.10.1/utils/ghc-pkg/install-inplace/bin/ghc-pkg --prefix=/NONEXISTENT --bindir=/NONEXISTENT --libdir=/NONEXISTENT --libexecdir=/NONEXISTENT --datadir=/NONEXISTENT --docdir=/NONEXISTENT --haddockdir=/NONEXISTENT --htmldir=/NONEXISTENT --libsubdir='$pkgid' --with-gcc=gcc --with-ld=/usr/bin/ld --configure-option='--prefix=/usr/local/stow/ghc-6.10.1' --configure-option=--with-cc=gcc --with-hsc2hs=/home/zooko/playground/ghc/ghc-6.10.1/utils/hsc2hs/install-inplace/bin/hsc2hs --ghc-option=-DSTAGE=2 And the complete output is: Configuring ghc-6.10.1... cabal-bin: At least the following dependencies are missing: Cabal -any, base <3, filepath >=1 && <1.2, haskell98 -any, hpc -any, template-haskell -any, unix -any Adding "-v" makes no difference. Adding "-v3" elicits: Configuring ghc-6.10.1... Creating dist-stage2 (and its parents) ("/home/zooko/playground/ghc/ghc-6.10.1/ghc/stage1-inplace/ghc",["--numeric-version"]) /home/zooko/playground/ghc/ghc-6.10.1/ghc/stage1-inplace/ghc is version 6.10.1 ("/home/zooko/playground/ghc/ghc-6.10.1/utils/ghc-pkg/install-inplace/bin/ghc-pkg",["--version"]) /home/zooko/playground/ghc/ghc-6.10.1/utils/ghc-pkg/install-inplace/bin/ghc-pkg is version 6.10.1 ("/home/zooko/playground/ghc/ghc-6.10.1/ghc/stage1-inplace/ghc",["--supported-languages"]) Reading installed packages... ("/home/zooko/playground/ghc/ghc-6.10.1/utils/ghc-pkg/install-inplace/bin/ghc-pkg",["dump","--global"]) cabal-bin: At least the following dependencies are missing: Cabal -any, base <3, filepath >=1 && <1.2, haskell98 -any, hpc -any, template-haskell -any, unix -any The complete output from running "make" is here: http://testgrid.allmydata.org:3567/uri/URI%3ACHK%3Alu4jyzcuktl7zkwazpgfotao6i%3Ar2olzx7x6ga2y5sbd533xi7qe24xd7k2wjr35vxzsywdzks33bpa%3A3%3A10%3A985759 -- View this message in context: http://www.nabble.com/Trouble-installing-ghc-6.10.1-on-linux-tp20419532p20876884.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From porges at porg.es Sat Dec 6 22:30:03 2008 From: porges at porg.es (George Pollard) Date: Sat Dec 6 22:23:28 2008 Subject: [Haskell-cafe] Origins of '$' Message-ID: <1228620603.22033.4.camel@porges-laptop> Hello Haskell-Caf?: This is a little bit random, but I was just wondering if anyone knew where the $ low-precedence parenthesis-eliminating application operator originated. The Haskell Report doesn't mention anything, and I can't search for "$" on Google. So... who thought it up? Does it originate in an earlier language, or is it uniquely Haskellish? :) - George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/d5862997/attachment.bin From dons at galois.com Sat Dec 6 23:49:34 2008 From: dons at galois.com (Don Stewart) Date: Sat Dec 6 23:42:39 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <1228620603.22033.4.camel@porges-laptop> References: <1228620603.22033.4.camel@porges-laptop> Message-ID: <20081207044934.GB26889@scytale.galois.com> porges: > Hello Haskell-Caf?: > > This is a little bit random, but I was just wondering if anyone knew > where the $ low-precedence parenthesis-eliminating application operator > originated. The Haskell Report doesn't mention anything, and I can't > search for "$" on Google. So... who thought it up? Does it originate in > an earlier language, or is it uniquely Haskellish? :) > If in doubt, you can search the early archives. http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/threads.html Early on there is a discussion about using $ for module import qualifiers, http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/msg00411.html use ' or $ for module qualifiers. The former would require But then by 91 we start to see things take shape, http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/msg00443.html haskell report version 1.1: beta-to-beta2 Will Partain 11 Jun 91 20:41 - ($$) :: (a -> b) -> a -> b - f $$ a = f a Where '$$' was removed from the draft 1.1 report. Then in the following thread we start to see the emergence of the low fixity $ that we know today. This is the first reference to it that I can find in the list: http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/msg00647.html syntax change Paul Hudak Sun, 1 Dec 1991 21:16:00 +0000 About the fixity of $ | The problem is that V1.1 does not allow things like: | | f x $ \y-> | g y $ | ... | | where the fixity of $ is defined as: | | infixr 0 $ Which suggests that $ was already in the 1.0 report going to SIGPLAN. Perhaps Paul or Simon could shed light on it? Anyone have the 1.0 report lying around to check if it was in earlier? Paul reiterates this in Aug 1992, http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/msg00889.html Of course, if you really don't like the parens, you can always write your example as: f $ x!i where ($) is defined in the prelude as: infixr 0 $ f $ x = f x -- Don From dominic.steinitz at blueyonder.co.uk Sun Dec 7 02:58:29 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Sun Dec 7 03:03:07 2008 Subject: pbkdf2 on hackage Re: Re[2]: [Haskell-cafe] Password hashing In-Reply-To: <910ddf450811270532n891cdfdw81effaebc1c5e87@mail.gmail.com> References: <910ddf450811270532n891cdfdw81effaebc1c5e87@mail.gmail.com> Message-ID: <493B8225.7070008@blueyonder.co.uk> Thomas Hartman wrote: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/PBKDF2 > > Since no one took up my code review request I just did the best I > Also I'm open to folding this into a more established crypto package > if there are any takers... psst, dominic. I've now had chance to review this and it looks a reasonable function to include in the package. I'd love a patch. First a few comments: 1. Experience has taught me that you need a few tests against known test vectors. If you look in the crypto package you will see there are several such test programs. You could either create your own or add to e.g. SymmetricTest (probably easiest). >>> pbkdf2' :: ([Word8] -> [Word8] -> [Word8]) -> Integer -> Integer -> >>> Integer -> Password -> Salt -> HashedPass 2. Any reason for the arguments being in a different order to that in the spec? >>> -- The spec says >>> -- Here, INT (i) is a four-octet encoding of the integer i, most >>> significant octet first. >>> -- I'm reading from the right... is this the right thing? 3. I don't know but some known test vectors will almost certainly flush this out. >>> toWord8s x = L.unpack . encode $ x >>> 4. Is there a guarantee that encode (I assume from Binary) does what is required? I think you are guaranteed that encode . decode == id but I don't know if any guarantee is made about the actual encoding (I haven't checked by the way). >>> --intToFourWord8s :: Integer -> [Word8] >>> intToFourWord8s i = let w8s = toWord8s $ i >>> in drop (length w8s -4) w8s 5. This looks slightly suspicious. It won't work in general. I assume you are sure that it is only ever used for the correctly sized Integers? Thanks for your contribution, Dominic. From ryani.spam at gmail.com Sun Dec 7 03:20:15 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun Dec 7 03:13:28 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <53396d9e0812061539k1dd299bt456420750bd84e92@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> <200812060032.21681.daniel.is.fischer@web.de> <53396d9e0812061539k1dd299bt456420750bd84e92@mail.gmail.com> Message-ID: <2f9b2d30812070020m52d633c5w1dca7903cdef4768@mail.gmail.com> On Sat, Dec 6, 2008 at 3:39 PM, Dmitri O.Kondratiev wrote: > Daniel, thanks! > I used your advice, it works, yet some more questions, if you don't mind :) > So: > {-- > Why showList returns a function of type: > type ShowS = String -> String > In fact showList returns a function which already contains all values > from list converted to a single string. > Why return function instead of a ready to use string? > --} ShowS is for efficiency; consider evaluating this: ( ( ( "1" ++ "2" ) ++ "3" ) ++ "4" ) ++ "5" ("1" ++ "2") evaluates to "12", allocating 1 list cell ("12" ++ "3") evalutes to "123", allocating 2 list cells ("123" ++ "4") evaluates to "1234", allocating 3 list cells ("1234" ++ "5") evaluates to "12345", allocating 4 list cells In general, n left-recursive applications of ++ take O(n^2) time and space. Now, instead, if you represent each string as a function which concatenates itself with its argument, you end up with this: ( '1': ), ( '2': ), etc. You can then "concatenate" these functions via function composition: ( ( ( ( '1': ) . ( '2':) ) . ( '3': ) ) . ( '4': ) ) . ( '5': ) This is already in normal form; but watch what happens when we apply it to []: ( ( ( ( ( '1': ) . ( '2':) ) . ( '3': ) ) . ( '4': ) ) . ( '5': ) ) "" => ( ( ( ( '1': ) . ( '2':) ) . ( '3': ) ) . ( '4': ) ) "5" , allocating 1 cons cell => ( ( ( '1': ) . ( '2':) ) . ( '3': ) ) "45", allocating 1 cons cell => ( ( '1': ) . ( '2':) ) "345", allocating 1 cons cell => ( '1': ) "2345", allocating 1 cons cell => "12345", allocating 1 cons cell This has allocations and time *linear* in the number of function compositions. > *ShowFleet> t2 fleet > "Ship \"HMS Fly\" is a \"sloop\" with 16 cannons <*> Ship \"HMS Surprise\" is a > \"frigate\" with 42 cannons <*> " > *ShowFleet> > > More questions: > 1)Where characters \" come from in this case? > 2)How showList function 'removes' characters \" from the output? > What magic goes behind the scenes here? 1) They come from the "show" instance for String. Try "putStrLn (t2 fleet)" instead. 2) There's no magic; if the result at the ghci prompt is an instance of Show, it calls show and prints the result. In the first case, the result was a [Fleet], which is an instance of Show, so show is called, which (in the instance (Show a => Show [a])) calls showList from Show Fleet, and prints the result. In the second case, you are evaluating a String; then showList from Show Char gives you the representation. It's the same as this: ghci> [1,2,3] [1,2,3] ghci> show [1,2,3] "[1,2,3]" ghci> "hello\nworld\n" "hello\nworld\n" ghci> putStr "hello\nworld\n" hello world -- ryan From bit at mutantlemon.com Sun Dec 7 04:23:33 2008 From: bit at mutantlemon.com (Bit Connor) Date: Sun Dec 7 04:16:45 2008 Subject: [Haskell-cafe] SDL program under MinGW In-Reply-To: <4e7aa0f80812061405g4fa493f4p6149509e935c56c1@mail.gmail.com> References: <4e7aa0f80812061405g4fa493f4p6149509e935c56c1@mail.gmail.com> Message-ID: <6205bd290812070123j34863633i2a93a0ee32d1e283@mail.gmail.com> Did you follow the instructions described in the WIN32 file? On Sat, Dec 6, 2008 at 2:05 PM, sam lee wrote: > Hi. > > I am using Windows Vista. > I installed the following: > > - ghc 6.8.3 (using official Windows binary installer) > - MinGW (from http://nuwen.net/mingw.html) > - SDL binding (from > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL) > > I am trying to compile the following program: > > module Main where > > import qualified Graphics.UI.SDL as SDL > > main = do > SDL.init [SDL.InitEverything] > SDL.quit > > I get the following error: > > C:\Users\client\code\sandbox>ghc --make Example.hs > Linking Example.exe ... > C:\MinGW\lib/libSDLmain.a(SDL_win32_main.o)(.text+0x409):SDL_win32_main.c: > undefined reference to `SDL_main' > > According to SDL faq > (http://www.libsdl.org/faq.php?action=listentries&category=4#48) I > should use "int main(int argc, char *argv[])", not "int main()" nor > "WinMain()". > > Can anyone compile the above snippet on windows machine? > I am using SDL library that is shipped with MinGW distribution that I'm using. > I also recompiled SDL haskell binding with official SDL windows binary > (http://www.libsdl.org/release/SDL-devel-1.2.13-mingw32.tar.gz). But I > get the same undefined reference to SDL_main linker error. > > Do I need to have specific main IO action so that SDL would work in Haskell? > > Thank you. > Sam. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From blancolioni at gmail.com Sun Dec 7 04:51:03 2008 From: blancolioni at gmail.com (Fraser Wilson) Date: Sun Dec 7 04:44:14 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <2f9b2d30812070020m52d633c5w1dca7903cdef4768@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> <200812060032.21681.daniel.is.fischer@web.de> <53396d9e0812061539k1dd299bt456420750bd84e92@mail.gmail.com> <2f9b2d30812070020m52d633c5w1dca7903cdef4768@mail.gmail.com> Message-ID: > > 1) They come from the "show" instance for String. Try "putStrLn (t2 > fleet)" instead. The show instance for Char. (I know you know this, I just have this weird fascination with the showList wart, although for the life of me I can't think of a better way of doing it) cheers, Fraser. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/134dd344/attachment-0001.htm From haberg at math.su.se Sun Dec 7 05:05:29 2008 From: haberg at math.su.se (Hans Aberg) Date: Sun Dec 7 04:58:44 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <1228620603.22033.4.camel@porges-laptop> References: <1228620603.22033.4.camel@porges-laptop> Message-ID: On 7 Dec 2008, at 04:30, George Pollard wrote: > This is a little bit random, but I was just wondering if anyone knew > where the $ low-precedence parenthesis-eliminating application > operator > originated. The Haskell Report doesn't mention anything, and I can't > search for "$" on Google. So... who thought it up? Does it > originate in > an earlier language, or is it uniquely Haskellish? :) As for the operator itself, it appears in Alonzo Church, "The Calculi of Lambda-Conversion", where it is written as exponentiation, like x^f, or typographically as f x One can define operators a ^ b := b(a) -- Application in inverse. (a * b)(x) := b(a(x)) -- Function composition in inverse. (a + b)(x) := a(x) * b(x) O(x) := I -- Constant function returning identity. I(x) := x -- Identity. and use them to define lambda calculus (suffices with the first four; Church reverses the order of "*"). Then on Church's natural number functionals, these are just the expected natural number operations. Hans From lrpalmer at gmail.com Sun Dec 7 05:34:54 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 7 05:28:03 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: References: <1228620603.22033.4.camel@porges-laptop> Message-ID: <7ca3f0160812070234k627d9a26he8915062f9922596@mail.gmail.com> On Sun, Dec 7, 2008 at 3:05 AM, Hans Aberg wrote: > One can define operators > a ^ b := b(a) -- Application in inverse. > (a * b)(x) := b(a(x)) -- Function composition in inverse. > (a + b)(x) := a(x) * b(x) > O(x) := I -- Constant function returning identity. > I(x) := x -- Identity. > and use them to define lambda calculus (suffices with the first four; > Church reverses the order of "*"). The simple elegance of writing this encoding just increased my already infinite love of Haskell by another cardinality. a .^ b = b a (a .* b) x = b (a x) (a .+ b) x = a x .* b x o x = i i x = x toNat x = x (+1) 0 fromNat n = foldr (.) id . replicate n Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/d9a85b23/attachment.htm From haberg at math.su.se Sun Dec 7 05:48:25 2008 From: haberg at math.su.se (Hans Aberg) Date: Sun Dec 7 05:41:38 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <7ca3f0160812070234k627d9a26he8915062f9922596@mail.gmail.com> References: <1228620603.22033.4.camel@porges-laptop> <7ca3f0160812070234k627d9a26he8915062f9922596@mail.gmail.com> Message-ID: <4FA01465-9C80-4CA2-9EF5-05804F38D779@math.su.se> On 7 Dec 2008, at 11:34, Luke Palmer wrote: > On Sun, Dec 7, 2008 at 3:05 AM, Hans Aberg wrote: > One can define operators > a ^ b := b(a) -- Application in inverse. > (a * b)(x) := b(a(x)) -- Function composition in inverse. > (a + b)(x) := a(x) * b(x) > O(x) := I -- Constant function returning identity. > I(x) := x -- Identity. > and use them to define lambda calculus (suffices with the first > four; Church reverses the order of "*"). > > The simple elegance of writing this encoding just increased my > already infinite love of Haskell by another cardinality. > > a .^ b = b a > (a .* b) x = b (a x) > (a .+ b) x = a x .* b x > o x = i > i x = x > > toNat x = x (+1) 0 > fromNat n = foldr (.) id . replicate n I have some more notes on this that you might translate, if possible (see below). If one implements integers this way, time complexity of the operators will be of high order, but it is in fact due to representing n in effect as 1+...+1. If one represents them, using these operators, in a positional notation system, that should be fixed, though there is a lot of other overhead. Hans Associativity: a*(b*c) = (a*b)*c, a+(b+c) = (a+b)+c RHS Relations: a^O = I, a^I = a a^(b * c) = (a^b)^c a^(b + c) = a^b * a^c a*(b + c) = a*b + a*c LHS Relations: I * a = a, O + a = a, O * a = I ^ a c functor (i.e., c(a*b) = c(a)*c(b), c(I) = I) => (a*b)^c = a^c * b^c (a+b)*c = a*c + b*c I^c = I If n in Natural, f: A -> A an endo-function, define f^n := I, if n = 0 f * ... * f, if n > 1 |-n times-| The natural number functionals, corresponding to Church's number functionals, are then defined by \bar n(f) := f^k If S(x) := x + 1 (regular integer addition), then \bar n(S)(0) = n Also write (following Hancock) log_x b := \lambda x b Then log_x I = O log_x x = I log_x(a * b) = log_x a + log_x b log_x(a ^ b) = (log_x a) * b, x not free in b. From p3k at iki.fi Sun Dec 7 06:14:57 2008 From: p3k at iki.fi (Pekka Karjalainen) Date: Sun Dec 7 06:08:07 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: References: Message-ID: <233457100812070314k8d7d97esb3001d28c7b9fed6@mail.gmail.com> On Sat, Dec 6, 2008 at 1:18 AM, Gwern Branwen wrote: > So: does anybody have a haiku I missed? Or even better, is anyone > feeling poetically inspired tonight? :) There's one by shapr in HaskellQuotes at the Wiki. < shapr> the snow falls slowly, the lambdas are lifting, weak head normal form Here's one by me: Without a kigo / or requisite syllables / haiku don't typecheck Pekka Karjalainen From tphyahoo at gmail.com Sun Dec 7 07:54:00 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Dec 7 07:47:09 2008 Subject: [Haskell-cafe] how to pipe in pure input with HSH? (Would be helpful for sending emails via sendmail/mailx via HSH interface) Message-ID: <910ddf450812070454rf74f8c9wf39f512dca166595@mail.gmail.com> {- I am trying to figure out a way to send email using HSH and I'm stumped. The problem is that there is no ShellCommand instance for a pure vanilla string, which can be piped into another ShellCommand. There is a ShellCommand String instance, but the string is a command to be executed. I defined PureInput wrapper around String in an attempt to get this working, but I'm stumped defining an fdInvoke method for it. class (Show a) => ShellCommand a where fdInvoke :: a -> System.Posix.Types.Fd -> System.Posix.Types.Fd -> [System.Posix.Types.Fd] -> IO () -> IO [InvokeResult] Can someone help out? Below is a stub. Thomas. -} import HSH newtype PureInput = PureInput { unpureinput :: String } deriving (Read,Show) -- This works fine, blah blah blah gets outputted demo1 = runIO $ ( ( ( ("echo blah blah blah") :: String) -|- ( "cat" :: String) ) :: PipeCommand String String ) -- This is what I want. Specify a pure input string, to be piped into another command. -- In this example it's cat, which isn't very usefuol. -- This would be useful, however, for sending email via sendmail or mailx, with variable input piped in. -- The result should be that "blah blah blah" is printed from cat, just as in demo1. demo2 = runIO $ (PureInput "blah blah blah") -|- ( "cat" :: String) -- How can/should this be done? instance ShellCommand PureInput where fdInvoke (PureInput justAString) ifd ofd closefd forkfunc = undefined From niklas.broberg at gmail.com Sun Dec 7 08:04:30 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Dec 7 07:57:38 2008 Subject: [Haskell-cafe] Haskell haikus In-Reply-To: References: Message-ID: > So: does anybody have a haiku I missed? Or even better, is anyone > feeling poetically inspired tonight? :) Sunday mornings* are made for poetic inspiration. :-) Trapped in a monad, use unsafePerformIO ! Purity tainted... Cheers, /Niklas * 2 pm is still morning right? From newhoggy at gmail.com Sun Dec 7 08:11:56 2008 From: newhoggy at gmail.com (John Ky) Date: Sun Dec 7 08:05:06 2008 Subject: [Haskell-cafe] Reading showables Message-ID: Hi, Is there a way to read Showables? main = do putStrLn $ show $ read Thanks -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/54fc32e8/attachment.htm From tphyahoo at gmail.com Sun Dec 7 08:38:41 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Dec 7 08:31:51 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: References: Message-ID: <910ddf450812070538v1aeb2f39p2264a5936691a699@mail.gmail.com> John, By convention, read . show is supposed to be id. However, in real life, this is often not the case. It all depends on the implementor, and this is a convention that seems to be broken pretty frequently. Often there is a show instance with no read or vice versa, and sometimes even when there is both read and show they are not inverses. Thomas. main = show . read Am 7. Dezember 2008 14:11 schrieb John Ky : > Hi, > > Is there a way to read Showables? > > main = do > putStrLn $ show $ read > > Thanks > > -John > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From tphyahoo at gmail.com Sun Dec 7 08:39:44 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Dec 7 08:32:53 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: References: Message-ID: <910ddf450812070539r5796bea1kff12bcd9a589b77f@mail.gmail.com> One more thing. If your Read/Show instances are created by data (or newtype) ... deriving (Read,Show) then read . show will do the right thing. Thomas. Am 7. Dezember 2008 14:11 schrieb John Ky : > Hi, > > Is there a way to read Showables? > > main = do > putStrLn $ show $ read > > Thanks > > -John > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From skynare at gmail.com Sun Dec 7 09:00:54 2008 From: skynare at gmail.com (sam lee) Date: Sun Dec 7 08:54:05 2008 Subject: [Haskell-cafe] SDL program under MinGW In-Reply-To: <6205bd290812070123j34863633i2a93a0ee32d1e283@mail.gmail.com> References: <4e7aa0f80812061405g4fa493f4p6149509e935c56c1@mail.gmail.com> <6205bd290812070123j34863633i2a93a0ee32d1e283@mail.gmail.com> Message-ID: <4e7aa0f80812070600i73b4550djba2158a4d09260c@mail.gmail.com> Yes, with some modifications. I used SDL-1.2.13, not SDL-1.2.12. Also, my Include-Dirs has include\SDL, not include: C:\Users\client\code\SDL-1.2.13\include\SDL If I don't put include\SDL, I get errors like Graphics\UI\SDL\General.hsc:1:17: SDL.h: No such file or directory And I used the following command to configure: C:\Users\client\Downloads\SDL-0.5.4>runghc Setup.lhs configure --prefix=C:\Users\client\haskell --datadir=$prefix\share --user it builds and installs fine. I only get linker error (undefined reference to SDL_main) when I compile a program that uses SDL binding. On Sun, Dec 7, 2008 at 4:23 AM, Bit Connor wrote: > Did you follow the instructions described in the WIN32 file? > > On Sat, Dec 6, 2008 at 2:05 PM, sam lee wrote: >> Hi. >> >> I am using Windows Vista. >> I installed the following: >> >> - ghc 6.8.3 (using official Windows binary installer) >> - MinGW (from http://nuwen.net/mingw.html) >> - SDL binding (from >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL) >> >> I am trying to compile the following program: >> >> module Main where >> >> import qualified Graphics.UI.SDL as SDL >> >> main = do >> SDL.init [SDL.InitEverything] >> SDL.quit >> >> I get the following error: >> >> C:\Users\client\code\sandbox>ghc --make Example.hs >> Linking Example.exe ... >> C:\MinGW\lib/libSDLmain.a(SDL_win32_main.o)(.text+0x409):SDL_win32_main.c: >> undefined reference to `SDL_main' >> >> According to SDL faq >> (http://www.libsdl.org/faq.php?action=listentries&category=4#48) I >> should use "int main(int argc, char *argv[])", not "int main()" nor >> "WinMain()". >> >> Can anyone compile the above snippet on windows machine? >> I am using SDL library that is shipped with MinGW distribution that I'm using. >> I also recompiled SDL haskell binding with official SDL windows binary >> (http://www.libsdl.org/release/SDL-devel-1.2.13-mingw32.tar.gz). But I >> get the same undefined reference to SDL_main linker error. >> >> Do I need to have specific main IO action so that SDL would work in Haskell? >> >> Thank you. >> Sam. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From holgersiegel74 at yahoo.de Sun Dec 7 09:01:10 2008 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Sun Dec 7 08:54:25 2008 Subject: [Haskell-cafe] Data.Map.fromListWith In-Reply-To: <493AE9A7.7030900@cogito.org.uk> References: <493ADEF9.2050304@cogito.org.uk> <57526e770812061235v787c0741ha0e633308e6fd83b@mail.gmail.com> <493AE9A7.7030900@cogito.org.uk> Message-ID: <200812071501.10945.holgersiegel74@yahoo.de> On Saturday 06 December 2008 22:07:51 Paul Johnson wrote: > So we could have > > fromListWithZero :: Ord k => (a -> b -> b) -> b -> [(k, a)] -> Map k b > fromListWithZero combiner zero pairs = ... > > The first time a key is seen the combining function is called with > "zero" as its second argument. E.g. > > fromListWithZero (:) [] xs > > Or is that too much trouble? It could be made a bit more general and efficient: Every entry x that did not have to be combined with another will end up as an application (combiner zero x). Thus, you could also write a function fromListWithUnit :: Ord k => (a -> b -> b) -> (a -> b) -> [(k, a)] -> Map k b fromListWithUnit combiner unit pairs = ... and define fromListWithZero via fromListWithZero c z ps = fromListWithUnit c (c z) ps But there is fromListWithUnit c u = fromListWith c . map (\p ->(fst p, u (snd p))) So, you already have what you want. Regards, Holger From miguelimo38 at yandex.ru Sun Dec 7 09:58:51 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sun Dec 7 09:52:10 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: References: Message-ID: <4FBD5730-D040-421A-868A-3E02408D511C@yandex.ru> Given two different types T1 and T2, it's possible to have two different results of > let {x :: T1; x = read s} in show x and > let {x :: T2; x = read s} in show x so that neither of two "read"s fails. For example > let {x :: Int; x = read "1000000000000"} in show x produces the answer "-727379968". BTW, I'd love to be able to give default instances locally, so that something like > main = withdef Read Int {putStrLn $ show $ read "1000000000000"} would typecheck successfully. On 7 Dec 2008, at 16:11, John Ky wrote: > Hi, > > Is there a way to read Showables? > > main = do > putStrLn $ show $ read > > Thanks > > -John > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jefferson.r.heard at gmail.com Sun Dec 7 10:13:32 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sun Dec 7 10:06:41 2008 Subject: [Haskell-cafe] Dr Dobbs: Time to get good at functional programming Message-ID: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> Seen on Slashdot: http://www.ddj.com/development-tools/212201710;jsessionid=3MQLTTYJRPL3CQSNDLRSKH0CJUNN2JVN From apfelmus at quantentunnel.de Sun Dec 7 12:38:13 2008 From: apfelmus at quantentunnel.de (Apfelmus, Heinrich) Date: Sun Dec 7 12:31:27 2008 Subject: [Haskell-cafe] Re: Haskell haikus In-Reply-To: References: Message-ID: Gwern Branwen wrote: > Hi everyone. So today I finally got around to something long on my > todo list - a compilation of all the Haskell haikus I've seen around! > > It is at http://haskell.org/haskellwiki/Haiku > > But I'm afraid I only have 5, and Google doesn't turn up any more. > > So: does anybody have a haiku I missed? Or even better, is anyone > feeling poetically inspired tonight? :) drop autumn leaves until . all . pure . color . Left fail . frost otherwise Regards, H. Apfelmus From jason.dusek at gmail.com Sun Dec 7 12:54:43 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Dec 7 12:47:51 2008 Subject: [Haskell-cafe] Dr Dobbs: Time to get good at functional programming In-Reply-To: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> Message-ID: <42784f260812070954wd9962besae999e9adcc19bfb@mail.gmail.com> Too bad they didn't pimp Haskell as practical. -- _jsn From gwern0 at gmail.com Sun Dec 7 12:55:51 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Dec 7 12:49:00 2008 Subject: [Haskell-cafe] Re: Haskell haikus In-Reply-To: References: Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Sun, Dec 7, 2008 at 12:38 PM, Apfelmus, Heinrich wrote: > Gwern Branwen wrote: >> Hi everyone. So today I finally got around to something long on my >> todo list - a compilation of all the Haskell haikus I've seen around! >> >> It is at http://haskell.org/haskellwiki/Haiku >> >> But I'm afraid I only have 5, and Google doesn't turn up any more. >> >> So: does anybody have a haiku I missed? Or even better, is anyone >> feeling poetically inspired tonight? :) > > > drop autumn leaves > until . all . pure . color . Left > fail . frost otherwise > > > Regards, > H. Apfelmus That's nice. I've added that one, Niklas's, and Pekka's - as well as that one of shapr's from Lambdabot. That brings us up to 18 Haskell haikus. Not too shabby! - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkk8DicACgkQvpDo5Pfl1oIzuACeKSsNvX7pzU+WSIn76MoS7t4d vCUAoIZ0Jk8fYsvILMZl0heoe2dvuadS =DUzf -----END PGP SIGNATURE----- From mailing_list at istitutocolli.org Sun Dec 7 13:08:28 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Sun Dec 7 13:01:42 2008 Subject: [Haskell-cafe] FFI, TH or GHCI, foreign bindings and the linker(s) Message-ID: <20081207180828.GA26345@Andrea.Nowhere.net> Hello, I know that this is somehow a recurring question, still the archives have not been helpful for finding a working solution. I'm writing the bindings[1] to bibutils[2], a set of utilities for converting from and to different bibliographic databases (MODS, bibtex, etc.). bibutilis uses a static library (which is not installed) to build a set of different binaries which are the installed utilities. Suppose I build the library in /tmp/bibutils. If I build the haskell bindings (hs-bibutils) with: runhaskell Setup.lhs configure --extra-include-dirs=/tmp/bibutils/lib --extra-lib-dirs=/tmp/bibutils/lib where libbibutils.a and the header files are located, then I can build a simple test[3] program with ghc --make test.hs and it works perfectly. When I tried to link citeproc-hs to hs-bibutils everything worked fine, too. But when I tried building pandoc, which uses the Template Haskell extension to generate some code at compilation time, I got a linker error when TH started its process: [...] [ 6 of 29] Compiling Text.Pandoc.ODT ( Text/Pandoc/ODT.hs, dist/build/Text/Pandoc/ODT.o ) Loading package ghc-prim ... linking ... done. [...] Loading package template-haskell ... linking ... done. ghc: /tmp/bibutils_3.43/lib/bibutils.o: unknown symbol `fields_add' Loading package hs-bibutils-0.1 ... linking ... ghc: unable to load package `hs-bibutils-0.1' So I went back to the test file with the original bindings. If I try to load it and run it on ghci I get the very same error: Prelude Main> main Loading package syb ... linking ... done. Loading package hs-bibutils-0.1 ... linking ... : /tmp/bibutils/lib/bibutils.o: unknown symbol `fields_add' ghc: unable to load package `hs-bibutils-0.1' After searching the we I found this: http://article.gmane.org/gmane.comp.lang.haskell.cafe/23635 which states that GHCi cannot load static libraries (the same can be argued by reading the GHCi docs, indeed). After reading this thread: http://article.gmane.org/gmane.comp.lang.haskell.cafe/40412 I came to know that GHCi and GHC are not using the same linker, and, as far as I understand, TH uses the first one too. So I tried to build a dynamic library. ar -t /tmp/bibutils/lib/libbibutils.a to get the list of objects to link with: gcc -shared -o libbibutils.so *.o after compiling them with the -fPIC flag. But this library is not being loaded because of some undefined symbols: lib/libbibutils.so: undefined reference to `corps' lib/libbibutils.so: undefined reference to `asis' lib/libbibutils.so: undefined reference to `progname' These symbols refer to some variables defined as external entities, for instance: extern char progname[]; these entities are initialized by a stub.c file in the Haskell bindings: http://code.haskell.org/~arossato/hs-bibutils/cbits/stub.c Unfortunately my knowledge of such low level stuff is very very limited and I'm not seeing any way out. Is there one? Thanks, Andrea [1] http://code.haskell.org/~arossato/hs-bibutils/ [2] http://www.scripps.edu/~cdputnam/software/bibutils/ [3] the test.hs file import Text.Bibutils main :: IO () main = do init_globals "mods2bibtex" bibl <- bibl_init param <- bibl_initparams mods_in bibtex_out setFormatOpts param [bibout_brackets, bibout_uppercase] setBOM param setVerbose param bibl_read param bibl "/tmp/prova.biblio" mods_in bibl_write param bibl "-" bibtex_out return () From dons at galois.com Sun Dec 7 13:11:54 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 7 13:04:58 2008 Subject: [Haskell-cafe] Dr Dobbs: Time to get good at functional programming In-Reply-To: <42784f260812070954wd9962besae999e9adcc19bfb@mail.gmail.com> References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> <42784f260812070954wd9962besae999e9adcc19bfb@mail.gmail.com> Message-ID: <20081207181154.GC30956@scytale.galois.com> jason.dusek: > Too bad they didn't pimp Haskell as practical. It looked like an archaic view of Haskell based on reading wikipedia, imo. Perhaps we should take charge of the wikipedia page, if it is that influential. From inforichland at gmail.com Sun Dec 7 13:49:39 2008 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Sun Dec 7 13:42:47 2008 Subject: [Haskell-cafe] Dr Dobbs: Time to get good at functional programming In-Reply-To: <4335a3260812071048q24b5ad67g698f3db039e17e00@mail.gmail.com> References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> <42784f260812070954wd9962besae999e9adcc19bfb@mail.gmail.com> <20081207181154.GC30956@scytale.galois.com> <4335a3260812071048q24b5ad67g698f3db039e17e00@mail.gmail.com> Message-ID: <4335a3260812071049h4a52e35epf5036afbd9e8df7a@mail.gmail.com> Amen to that. People who haven't really given a fair look at functional langauges (Haskell in particular) seem to have a very poor conception of them. Again, this seems to especially be a problem with Haskell (i.e., the whole "monads are hard" thing)... If this is where people are getting their information from, it would definitely behoove the Haskell community to update its image to further Haskell and FP in general :) On Sun, Dec 7, 2008 at 12:11 PM, Don Stewart wrote: > jason.dusek: > > Too bad they didn't pimp Haskell as practical. > > It looked like an archaic view of Haskell based on reading wikipedia, > imo. Perhaps we should take charge of the wikipedia page, if it is that > influential. > _______________________________________________ > 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/20081207/0e059c69/attachment.htm From dons at galois.com Sun Dec 7 14:05:57 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 7 13:59:03 2008 Subject: [Haskell-cafe] Dr Dobbs: Time to get good at functional programming In-Reply-To: <20081207181154.GC30956@scytale.galois.com> References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> <42784f260812070954wd9962besae999e9adcc19bfb@mail.gmail.com> <20081207181154.GC30956@scytale.galois.com> Message-ID: <20081207190557.GG30956@scytale.galois.com> dons: > jason.dusek: > > Too bad they didn't pimp Haskell as practical. > > It looked like an archaic view of Haskell based on reading wikipedia, > imo. Perhaps we should take charge of the wikipedia page, if it is that > influential. To those reading, the wikipedia article is here, http://en.wikipedia.org/wiki/Haskell_(programming_language) Feel free to improve it. We have lots of good content about the current state of the language, compilers, libraries, applications, domains of use, size of community, commercial use and so on on haskell.org, so just apply what you know. Perhaps we can get a better article out of this that more accurately reflects the thousands of people reading this list and using Haskell, the thounsand or so libraries, our excellent optimizing compiler, and the broad range of apps being produced. -- Don From simonpj at microsoft.com Sun Dec 7 15:34:40 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Sun Dec 7 15:27:50 2008 Subject: [Haskell-cafe] know a workaround for greedy context reduction? In-Reply-To: <5ce89fb50812051923j583cd86dwf09bfcf5d6ea2f46@mail.gmail.com> References: <5ce89fb50812051923j583cd86dwf09bfcf5d6ea2f46@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C332818EF027@EA-EXMSG-C334.europe.corp.microsoft.com> This is perfectly reasonable behavior I'm afraid. If you do ":info d" you'll get d's original type signature. But ":type" takes an *arbitrary expression* (in this case a single variable 'd', and figures out its most general type. You could have said ":t (3*3)" for example. In this case, when inferring the most general type of the expression "d", GHC tries to simplify the context (D a), and uses the instance declaration to reduce it to (C a). And then it can't simplify it further. But you *might* have had instance C a somewhere, in which case it'd have been able to simplify the (C a) away. So GHC must try that route. If it fails, you want it to "back up" to a notationally more convenient type, but GHC can't do that, I'm afraid Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe- | bounces@haskell.org] On Behalf Of Nicolas Frisby | Sent: 06 December 2008 03:23 | To: haskell Cafe | Subject: [Haskell-cafe] know a workaround for greedy context reduction? | | With these three declarations | | {-# LANGUAGE FlexibleInstances #-} | {-# LANGUAGE UndecidableInstances #-} | | class C a where c :: a | class C a => D a where d :: a | instance C a => D a where d = c | | ghci exhibits this behavior: | | *> :t d | d :: (C a) => a | | Where I would prefer "d :: (D a) => a". In my actual examples, the | context is much larger and I can't involve overlapping instances. Is | there a known workaround? I didn't find a related bug on the GHC trac, | and I don't know if other compilers behave in the same way. | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From doaitse at swierstra.net Sun Dec 7 16:05:30 2008 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Sun Dec 7 15:58:44 2008 Subject: [Haskell-cafe] [Announce] TTTAS (with excuse for second attempt to post) Message-ID: <5AF74C18-ED38-4C1F-A9FC-512AD7AEEE9A@swierstra.net> We are pleased to announce the availability of the package "TTTAS", which contains the code associated with our paper at the coming TLDI workshop: \@inproceedings{ BSV09, author = {Arthur Baars and S. Doaitse Swierstra and Marcos Viera}, title = {Typed Transformations of Typed Abstract Syntax}, booktitle = {TLDI '09: fourth ACM SIGPLAN Workshop on Types in Language Design and Implementation}, year = {2009}, location = {Savannah, Georgia, USA}, publisher = {ACM}, address = {New York, NY, USA}, } For more information see: http://www.cs.uu.nl/wiki/bin/view/Center/TTTAS Arthur Baars Marcos Viera Doaitse Swierstra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/23ab5283/attachment.htm From doaitse at swierstra.net Sun Dec 7 16:07:22 2008 From: doaitse at swierstra.net (S.Doaitse Swierstra) Date: Sun Dec 7 16:00:45 2008 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: ChristmasTree 0.1 (excuses for second attempt) In-Reply-To: <49399A47.1020103@van.steenbergen.nl> References: <1213789520.15010.837.camel@localhost> <7A61F72B-55DD-4390-AA51-1A6B6FBF2C31@swierstra.net> <49399A47.1020103@van.steenbergen.nl> Message-ID: <1B6E1D99-7B9E-4493-88B2-0EA4A54A5906@swierstra.net> We are pleased to announce the availability of the package "ChristmasTree", which contains the code associated with our paper at the last Haskell symposium: @inproceedings{1411296, author = {Marcos Viera and S. Doaitse Swierstra and Eelco Lempsink}, title = {Haskell, do you read me?: constructing and composing efficient top-down parsers at runtime}, booktitle = {Haskell '08: Proceedings of the first ACM SIGPLAN symposium on Haskell}, year = {2008}, isbn = {978-1-60558-064-7}, pages = {63--74}, location = {Victoria, BC, Canada}, doi = {http://doi.acm.org/10.1145/1411286.1411296}, publisher = {ACM}, address = {New York, NY, USA}, } The name of the package stands for: "Changing Haskell's Read Implementation Such That by Manipulating Abstract Syntax Trees it Reads Expressions Efficiently" which, given the time of year, seems appropriate. Feel free to download and unpack this "present" at what for the Dutch is called "Sinterklaasavond" (http://en.wikipedia.org/wiki/Sinterklaas), Arthur Baars Marcos Viera Eelco Lempsink Doaitse Swierstra PS: the package uses our library supporting transformation of typed abstract syntax, which we placed in a separate package TTTAS From niklas.broberg at gmail.com Sun Dec 7 16:28:47 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Dec 7 16:21:55 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: > The full list of pragmas supported by 0.4.4 is: SOURCE, RULES, > DEPRECATED, WARNING, INLINE, NOINLINE, SPECIALISE, CORE, SCC, > GENERATED and UNPACK. The newly released version 0.4.4.1 adds to the list of pragmas supported by adding support for the following: LANGUAGE, OPTIONS, OPTIONS_{GHC, HUGS, NHC98, YHC, HADDOCK, your tool here}, INCLUDE and CFILES. The LANGUAGE pragma is checked for well-formedness (a comma-separated list of constructors) but no validation of the constructors is done. The other pragmas all have their contents unchecked and passed along as is. Apart from this, HSE now also parses any unrecognized pragma in option (e.g. LANGUAGE), declaration (e.g. RULES) or expression (e.g. SCC) position, allowing user-customized pragmas. Unrecognized pragmas in other positions will (unfortunately) give a parse error. If this ever means a problem for you - let me know! The only pragmas supported by GHC that HSE supports are, to my knowledge, ANN and LINE. I may add support for these in a near future, though I believe the syntax for the ANN pragma is still a bit in flux. Note that source files containing these pragmas can still be parsed by HSE, just like any other unrecognized pragmas in proper positions. > 0.4.4 is backwards incompatible with 0.4.3 for two constructors: > * The Module constructor (:: Module) now has an extra argument of type > 'Maybe WarningText', used for deprecated modules. > * The ImportDecl constructor (:: ImportDecl) now has an extra argument > of type Bool, stating whether the SOURCE pragma has been used for the > import. 0.4.4.1 is backwards incompatible with 0.4.4 by adding yet another argument to the Module constructor (:: Module) of type [OptionPragma], used to list the pragmas preceding the beginning of the module proper. Cheers and happy haskelling, /Niklas From niklas.broberg at gmail.com Sun Dec 7 16:35:40 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sun Dec 7 16:28:47 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: > The only pragmas supported by GHC that HSE supports are, to my > knowledge, ANN and LINE. Umm, right, insert a "does not" in the proper place there... Cheers, /Niklas From lemmih at gmail.com Sun Dec 7 16:39:51 2008 From: lemmih at gmail.com (Lemmih) Date: Sun Dec 7 16:32:59 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: On Sun, Dec 7, 2008 at 10:28 PM, Niklas Broberg wrote: >> The full list of pragmas supported by 0.4.4 is: SOURCE, RULES, >> DEPRECATED, WARNING, INLINE, NOINLINE, SPECIALISE, CORE, SCC, >> GENERATED and UNPACK. > > The newly released version 0.4.4.1 adds to the list of pragmas > supported by adding support for the following: LANGUAGE, OPTIONS, > OPTIONS_{GHC, HUGS, NHC98, YHC, HADDOCK, your tool here}, INCLUDE and > CFILES. The LANGUAGE pragma is checked for well-formedness (a > comma-separated list of constructors) but no validation of the > constructors is done. The other pragmas all have their contents > unchecked and passed along as is. > > Apart from this, HSE now also parses any unrecognized pragma in option > (e.g. LANGUAGE), declaration (e.g. RULES) or expression (e.g. SCC) > position, allowing user-customized pragmas. Unrecognized pragmas in > other positions will (unfortunately) give a parse error. If this ever > means a problem for you - let me know! > > The only pragmas supported by GHC that HSE supports are, to my > knowledge, ANN and LINE. I may add support for these in a near future, > though I believe the syntax for the ANN pragma is still a bit in flux. > Note that source files containing these pragmas can still be parsed by > HSE, just like any other unrecognized pragmas in proper positions. > >> 0.4.4 is backwards incompatible with 0.4.3 for two constructors: >> * The Module constructor (:: Module) now has an extra argument of type >> 'Maybe WarningText', used for deprecated modules. >> * The ImportDecl constructor (:: ImportDecl) now has an extra argument >> of type Bool, stating whether the SOURCE pragma has been used for the >> import. > > 0.4.4.1 is backwards incompatible with 0.4.4 by adding yet another > argument to the Module constructor (:: Module) of type [OptionPragma], > used to list the pragmas preceding the beginning of the module proper. > > Cheers and happy haskelling, Are SrcSpan's on the TODO list? -- Cheers, Lemmih From nicolas.frisby at gmail.com Sun Dec 7 17:57:32 2008 From: nicolas.frisby at gmail.com (Nicolas Frisby) Date: Sun Dec 7 17:50:40 2008 Subject: [Haskell-cafe] know a workaround for greedy context reduction? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C332818EF027@EA-EXMSG-C334.europe.corp.microsoft.com> References: <5ce89fb50812051923j583cd86dwf09bfcf5d6ea2f46@mail.gmail.com> <638ABD0A29C8884A91BC5FB5C349B1C332818EF027@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <5ce89fb50812071457y59034da5u449e99d7d3c77999@mail.gmail.com> Seems I got ahead of myself with the bug search. I was thinking bug because when I ascribe a type, I expect the compiler to check and then respect it. With the "most general type" specification of the ":type" command in mind, this does make sense. Thanks for improving my internal notion of ":type". My grumble may seem more legitimate from a library perspective. I implement a type-level function Append with three (preferably hidden) ancillary classes and a single instance in order to support the multiple modalities (in the Mercury sense) of the Append logic function. When a user defines another function that uses the append method, it's obfuscating for the user to see the internal classes in the inferred type. That's what I would like to workaround. If we consider class C the internal and consider class D and the function f the library's exposed interface, then I'd like to see C instead of D in the context of f and any function the user defines with f, especially when I have supplied a preferred type for f. > f :: D a => () -> a > f () = d > *> :t f > f :: (C a) => () -> a No dice? Thanks again, Nick On Sun, Dec 7, 2008 at 2:34 PM, Simon Peyton-Jones wrote: > This is perfectly reasonable behavior I'm afraid. If you do ":info d" you'll get d's original type signature. But ":type" takes an *arbitrary expression* (in this case a single variable 'd', and figures out its most general type. You could have said ":t (3*3)" for example. > > In this case, when inferring the most general type of the expression "d", GHC tries to simplify the context (D a), and uses the instance declaration to reduce it to (C a). And then it can't simplify it further. But you *might* have had > instance C a > somewhere, in which case it'd have been able to simplify the (C a) away. So GHC must try that route. If it fails, you want it to "back up" to a notationally more convenient type, but GHC can't do that, I'm afraid > > Simon > > | -----Original Message----- > | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe- > | bounces@haskell.org] On Behalf Of Nicolas Frisby > | Sent: 06 December 2008 03:23 > | To: haskell Cafe > | Subject: [Haskell-cafe] know a workaround for greedy context reduction? > | > | With these three declarations > | > | {-# LANGUAGE FlexibleInstances #-} > | {-# LANGUAGE UndecidableInstances #-} > | > | class C a where c :: a > | class C a => D a where d :: a > | instance C a => D a where d = c > | > | ghci exhibits this behavior: > | > | *> :t d > | d :: (C a) => a > | > | Where I would prefer "d :: (D a) => a". In my actual examples, the > | context is much larger and I can't involve overlapping instances. Is > | there a known workaround? I didn't find a related bug on the GHC trac, > | and I don't know if other compilers behave in the same way. > | _______________________________________________ > | Haskell-Cafe mailing list > | Haskell-Cafe@haskell.org > | http://www.haskell.org/mailman/listinfo/haskell-cafe > > From newhoggy at gmail.com Sun Dec 7 19:16:10 2008 From: newhoggy at gmail.com (John Ky) Date: Sun Dec 7 19:09:19 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: <910ddf450812070538v1aeb2f39p2264a5936691a699@mail.gmail.com> References: <910ddf450812070538v1aeb2f39p2264a5936691a699@mail.gmail.com> Message-ID: Hi Thomas, So "show . read" and "\x -> show (read x)" are actually mean different things? Also, I never suspected that something like this should succeed: putStrLn $ (read . show) $ "!@#%$^DFD" Thanks, -John On Mon, Dec 8, 2008 at 12:38 AM, Thomas Hartman wrote: > John, > > By convention, read . show is supposed to be id. > > However, in real life, this is often not the case. It all depends on > the implementor, and this is a convention that seems to be broken > pretty frequently. > > Often there is a show instance with no read or vice versa, and > sometimes even when there is both read and show they are not inverses. > > Thomas. > > main = show . read > > > > Am 7. Dezember 2008 14:11 schrieb John Ky : > > Hi, > > > > Is there a way to read Showables? > > > > main = do > > putStrLn $ show $ read > > > > Thanks > > > > -John > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/861adb18/attachment-0001.htm From newhoggy at gmail.com Sun Dec 7 19:28:56 2008 From: newhoggy at gmail.com (John Ky) Date: Sun Dec 7 19:22:04 2008 Subject: [Haskell-cafe] Is unsafePerformIO safe here? Message-ID: Hi, Is the following safe? moo :: TVar Int moo = unsafePerformIO $ newTVarIO 1 I'm interested in writing a stateful application, and I wanted to start with writing some IO functions that did stuff on some state and then test them over long periods of time in GHCi. I was worried I might be depending on some guarantees that aren't actually there, like moo being discarded and recreated inbetween invocations of different functions. Thanks, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/0956c07f/attachment.htm From tom.davie at gmail.com Sun Dec 7 19:51:15 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Sun Dec 7 19:44:28 2008 Subject: [Haskell-cafe] Is unsafePerformIO safe here? In-Reply-To: References: Message-ID: <7EB52303-2AA7-4CCE-A123-2EBF14260F58@gmail.com> On 8 Dec 2008, at 01:28, John Ky wrote: > Hi, > > Is the following safe? > > moo :: TVar Int > moo = unsafePerformIO $ newTVarIO 1 > > I'm interested in writing a stateful application, and I wanted to > start with writing some IO functions that did stuff on some state > and then test them over long periods of time in GHCi. > > I was worried I might be depending on some guarantees that aren't > actually there, like moo being discarded and recreated inbetween > invocations of different functions. Define safe... In this case though, I would guess it's not safe. The compiler is free to call moo zero, one or many times depending on its evaluation strategy, and when it's demanded. It's possible that your TVar will get created many times, and different values returned by the "constant" moo. That sounds pretty unsafe to me. Bob From jonathanccast at fastmail.fm Sun Dec 7 20:08:33 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sun Dec 7 20:01:42 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: References: <910ddf450812070538v1aeb2f39p2264a5936691a699@mail.gmail.com> Message-ID: <1228698513.5976.5.camel@jonathans-macbook> On Mon, 2008-12-08 at 11:16 +1100, John Ky wrote: > Hi Thomas, > > So "show . read" and "\x -> show (read x)" are actually mean different > things? No. Of course not. But there's no guarantee that show (read x) = x either. > Also, I never suspected that something like this should succeed: > > putStrLn $ (read . show) $ "!@#%$^DFD" Of course it succeeds. You put the `show' first; show always succeeds and --- for the Show instances in the Prelude, plus some --- read (show x) = x for finite, total x. (Note that read . show /= show . read; they don't even have the same type! show . read :: forall alpha. Show alpha => String -> String read . show :: forall alpha beta. (Read alpha, Show beta) => alpha -> beta NB: The reason why show . read is illegal should be screaming out at you about now. The caveat --- other than the one I mentioned above --- to claims that read . show = id should also be screaming out.) jcc From newhoggy at gmail.com Sun Dec 7 20:44:37 2008 From: newhoggy at gmail.com (John Ky) Date: Sun Dec 7 20:37:45 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: <1228698513.5976.5.camel@jonathans-macbook> References: <910ddf450812070538v1aeb2f39p2264a5936691a699@mail.gmail.com> <1228698513.5976.5.camel@jonathans-macbook> Message-ID: Thanks for the clarification. They're all the same, as you've explained: Prelude> putStrLn $ (show . read) "123" *** Exception: Prelude.read: no parse Prelude> putStrLn $ show $ read "123" *** Exception: Prelude.read: no parse Prelude> putStrLn $ (\x -> show (read x)) "123" *** Exception: Prelude.read: no parse -John On Mon, Dec 8, 2008 at 12:08 PM, Jonathan Cast wrote: > On Mon, 2008-12-08 at 11:16 +1100, John Ky wrote: > > Hi Thomas, > > > > So "show . read" and "\x -> show (read x)" are actually mean different > > things? > > No. Of course not. But there's no guarantee that > > show (read x) = x > > either. > > > Also, I never suspected that something like this should succeed: > > > > putStrLn $ (read . show) $ "!@#%$^DFD" > > Of course it succeeds. You put the `show' first; show always succeeds > and --- for the Show instances in the Prelude, plus some --- > > read (show x) = x > > for finite, total x. > > (Note that read . show /= show . read; they don't even have the same > type! > > show . read :: forall alpha. Show alpha => String -> String > read . show :: forall alpha beta. (Read alpha, Show beta) => alpha -> > beta > > NB: The reason why show . read is illegal should be screaming out at you > about now. The caveat --- other than the one I mentioned above --- to > claims that read . show = id should also be screaming out.) > > jcc > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/55c6de10/attachment.htm From newhoggy at gmail.com Sun Dec 7 20:52:13 2008 From: newhoggy at gmail.com (John Ky) Date: Sun Dec 7 20:45:20 2008 Subject: [Haskell-cafe] Is unsafePerformIO safe here? In-Reply-To: <7EB52303-2AA7-4CCE-A123-2EBF14260F58@gmail.com> References: <7EB52303-2AA7-4CCE-A123-2EBF14260F58@gmail.com> Message-ID: Does that mean there is no place to store state while running the interpreter and that I have to put the state elsewhere such as a file? I was hoping to avoid that as I'm only prototyping at this stage and don't want to write a persistent layer just yet. Thanks -John On Mon, Dec 8, 2008 at 11:51 AM, Thomas Davie wrote: > > On 8 Dec 2008, at 01:28, John Ky wrote: > > Hi, >> >> Is the following safe? >> >> moo :: TVar Int >> moo = unsafePerformIO $ newTVarIO 1 >> >> I'm interested in writing a stateful application, and I wanted to start >> with writing some IO functions that did stuff on some state and then test >> them over long periods of time in GHCi. >> >> I was worried I might be depending on some guarantees that aren't actually >> there, like moo being discarded and recreated inbetween invocations of >> different functions. >> > > Define safe... In this case though, I would guess it's not safe. The > compiler is free to call moo zero, one or many times depending on its > evaluation strategy, and when it's demanded. It's possible that your TVar > will get created many times, and different values returned by the "constant" > moo. > > That sounds pretty unsafe to me. > > Bob > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/5140c0c5/attachment.htm From ok at cs.otago.ac.nz Sun Dec 7 21:02:44 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Dec 7 20:55:58 2008 Subject: [Haskell-cafe] Re: Haskell haikus In-Reply-To: References: Message-ID: <93D5EDEF-A598-4660-89DE-C6E105D070A2@cs.otago.ac.nz> It's proving remarkably hard to pin down just what a "Haiku" is supposed to be in English. Taking the 3-5-3 syllable pattern, how about Soft rain falls while Haskell infers all my types. (As it happens, soft rain _is_ falling right now.) From tom.davie at gmail.com Sun Dec 7 21:06:49 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Sun Dec 7 21:00:00 2008 Subject: [Haskell-cafe] Re: Haskell haikus In-Reply-To: <93D5EDEF-A598-4660-89DE-C6E105D070A2@cs.otago.ac.nz> References: <93D5EDEF-A598-4660-89DE-C6E105D070A2@cs.otago.ac.nz> Message-ID: <72ED1BF1-3F7E-4933-8A8C-F1F83145872D@gmail.com> On 8 Dec 2008, at 03:02, Richard O'Keefe wrote: > It's proving remarkably hard to pin down just > what a "Haiku" is supposed to be in English. > Taking the 3-5-3 syllable pattern, how about > > Soft rain falls > while Haskell infers > all my types. I always thought that Haikus had a seven five seven pattern, no? Bob From patperry at stanford.edu Sun Dec 7 21:09:44 2008 From: patperry at stanford.edu (Patrick Perry) Date: Sun Dec 7 21:02:53 2008 Subject: [Haskell-cafe] ANN: permutation-0.2 Message-ID: <99E8C422-D484-4667-AB07-97B8AA09D9AC@stanford.edu> Hi Everyone, I've uploaded a new version of the permutation library to hackage. Here is the package description: This library includes data types for storing permutations. It implements pure and impure types, the latter which can be modified in-place. The main utility of the library is converting between the linear representation of a permutation to a sequence of swaps. This allows, for instance, applying a permutation or its inverse to an array with O(1) memory use. . Much of the interface for the library is based on the permutation functions in the GNU Scientific Library (GSL). Here's the url: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/permutation Patrick From chak at cse.unsw.edu.au Sun Dec 7 21:10:34 2008 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Sun Dec 7 21:03:44 2008 Subject: [Haskell-cafe] Could FDs help usurp an ATs syntactic restriction? In-Reply-To: <5ce89fb50812041938s1df748e7vdaead568b53fce9d@mail.gmail.com> References: <5ce89fb50812041938s1df748e7vdaead568b53fce9d@mail.gmail.com> Message-ID: <13D4E0F0-04B2-4A38-8534-2A20011FA887@cse.unsw.edu.au> Nicolas Frisby: >> From the error below, I'm inferring that the RHS of the associated > type definition can only contain type variables from the instance > head, not the instance context. I didn't explicitly see this > restriction when reading the GHC/Type_families entry. > > Could perhaps the "a b -> bn" functional dependency of the TypeEq > class lift this restriction for bn? This isn't my ball park, but that > idea has my hopes up :). > > > {-# LANGUAGE TypeFamilies #-} > > import TypeEq > > -- Attempting to encapsulate TypeEq behind an associated type. > > class EQ a b where > type BN a b > > instance TypeEq a b bn => EQ a b where > type BN a b = bn > > > results in an error > > > /tmp/Test.hs:9:16: Not in scope: type variable `bn' > Failed, modules loaded: none. > GHC is right, you cannot use 'bn' in the definition of the type family instance. I agree that the documentation needs to make this clearer. Generally, > class EQ a b where > type BN a b > > instance TypeEq a b bn => EQ a b where > type BN a b = bn is really just syntactic sugar for > type family BN a b > class EQ a b > > type instance BN a b = bn > instance TypeEq a b bn => EQ a b where it is clear that 'bn' is not in scope in the rhs of the type instance. Unfortunately, you cannot wrap a type class constraint into a type synonym family (independent of whether it is associated or not). Incidentally, type equalities (which are part of the type family implementation) enable a much more compact definition of the type equality predicate: data True; data False; class EqTyP a b result instance (result ~ True) => EqTyP a a result instance (result ~ False) => EqTyP a b result Manuel From lrpalmer at gmail.com Sun Dec 7 21:15:04 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 7 21:08:12 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: References: <910ddf450812070538v1aeb2f39p2264a5936691a699@mail.gmail.com> <1228698513.5976.5.camel@jonathans-macbook> Message-ID: <7ca3f0160812071815t5c7adad2s214de0fc214215c4@mail.gmail.com> 2008/12/7 John Ky > Thanks for the clarification. > > They're all the same, as you've explained: > > Prelude> putStrLn $ (show . read) "123" > *** Exception: Prelude.read: no parse The "no parse" is an artifact of defaulting: Prelude> putstrLn $ (show . read) "()" () It's because ghci defaults the free type variables to (). The signatures for show and read are: show :: (Show a) => a -> String read :: (Read a) => String -> a So when you do show . read, you get String -> String, but where did the a's go? What type were they (what type is "read" trying to parse)? Ghci makes them (), because it's weird like that. A compiler will complain that there is an unconstrained type variable that it doesn't know what to do with. You can constrain it yourself with something like: showAs :: (Show a) => a -> a -> String showAs typ x = show (x `asTypeOf` typ) Then: Prelude> putStrLn $ (showAs (undefined::Int) . read) "123" 123 But this situation doesn't arise in practice, because usually you do something with a value you've read other than just printing it, and that something will determine the type to read. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/6848b15b/attachment.htm From h8spawn at googlemail.com Sun Dec 7 21:16:37 2008 From: h8spawn at googlemail.com (=?UTF-8?Q?S._G=C3=BCnther?=) Date: Sun Dec 7 21:09:44 2008 Subject: [Haskell-cafe] Problem with System.Random.randoms Message-ID: Hi, I have a small problem with System.Random.randoms. I need a rather large number of random numbers but the following program consumes a huge amount of memory. I terminated it when it used up more than 2 Gb: module Main where import System.Random n :: Int n = maxBound main = do g <- getStdGen print $ length $ take n $ ((randoms g)::[Int]) On the other hand using take n $ [1..] it runs in constant space. Am I doing something wrong? Or should I just abandon randoms and use the more primitive functions in System.Random? Thanks in advance S. G?nther From ok at cs.otago.ac.nz Sun Dec 7 21:21:06 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Dec 7 21:14:19 2008 Subject: [Haskell-cafe] Re: Haskell haikus In-Reply-To: <72ED1BF1-3F7E-4933-8A8C-F1F83145872D@gmail.com> References: <93D5EDEF-A598-4660-89DE-C6E105D070A2@cs.otago.ac.nz> <72ED1BF1-3F7E-4933-8A8C-F1F83145872D@gmail.com> Message-ID: On 8 Dec 2008, at 3:06 pm, Thomas Davie wrote: > > On 8 Dec 2008, at 03:02, Richard O'Keefe wrote: > >> It's proving remarkably hard to pin down just >> what a "Haiku" is supposed to be in English. >> Taking the 3-5-3 syllable pattern, how about >> >> Soft rain falls >> while Haskell infers >> all my types. > > I always thought that > Haikus had a seven five > seven pattern, no? No. (1) It's 5-7-5. (2) Those numbers are not SYLLABLE counts but MORA counts. (See the Wikipedia article on Haiku.) (3) According to http://www.ahapoetry.com/keirule.htm, "Today, many bilingual poets and translators in the mainstream North American haiku scene agree that something in the vicinity of 11 English syllables is a suitable approximation of 17 Japanese syllables, in order to convey about the same amount of information as well as the brevity and the fragmented quality found in Japanese haiku. As to the form, some American poets advocate writing in 3-5-3 syllables or 2-3-2 accented beats." There is also a Wikipedia article "Haiku in English", which states that "It is impossible to single out any current style or format or subject matter as definitive. Some of the more common practices in English are: * Use of three (or fewer) lines of 17 or fewer syllables; * Use of a season word (kigo); * Use of a cut or kireji (sometimes indicated by a punctuation mark) to contrast and compare, implicitly, two events, images, or situations. The average length of the haiku appearing in the main English-language journals is about 13 syllables; few have a symmetrical line arrangement such as 5-7-5 or 3-6-3. Instead, current haiku poets (haijin) are more concerned with their haiku being expressed in 'one breath' and the extent to which the two phrases focus on description ("showing" as opposed to "telling") and not on having a "correct" syllable count." The rain reference is my kigo, and 'while' is my kireji. I think. I also _think_ it fits the "one breath" criterion, but what do I know? In my room Haskell humbles me; Look, green leaves! From lrpalmer at gmail.com Sun Dec 7 21:28:04 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 7 21:21:11 2008 Subject: [Haskell-cafe] Is unsafePerformIO safe here? In-Reply-To: References: <7EB52303-2AA7-4CCE-A123-2EBF14260F58@gmail.com> Message-ID: <7ca3f0160812071828mcaba85ap83b9a4bd6e2e4aed@mail.gmail.com> 2008/12/7 John Ky > Does that mean there is no place to store state while running the > interpreter and that I have to put the state elsewhere such as a file? I > was hoping to avoid that as I'm only prototyping at this stage and don't > want to write a persistent layer just yet. Bob is right, that technically it is unsafe. However, in GHC (I can't speak for the others) you can make it safe by forcing it not to inline. Then, IIRC, you are guaranteed (only in GHC, not in Haskell) that it will be only created once: moo :: TVar Int {-# NOINLINE moo #-} moo = unsafePerformIO $ newTVarIO 1 Correct, you cannot have global state in safe Haskell. Make of that what you will, YMMV, personally I like it (it has positive implications in terms of semantics and reasoning). You have to put state elsewhere, but "such as a file" is a little extreme. Make it at the GHCi prompt (if there is more than a teeny bit of initialization, I usually define a helper function to make this as easy as possible). Then pass it around or put your computation in a ReaderT (same thing). You're going to be passing it around when you write your real application anyway, right? Also, as your application matures, you know your persistence layer is probably already done for you in Data.Binary :-) Luke > > Thanks > > -John > > > On Mon, Dec 8, 2008 at 11:51 AM, Thomas Davie wrote: > >> >> On 8 Dec 2008, at 01:28, John Ky wrote: >> >> Hi, >>> >>> Is the following safe? >>> >>> moo :: TVar Int >>> moo = unsafePerformIO $ newTVarIO 1 >>> >>> I'm interested in writing a stateful application, and I wanted to start >>> with writing some IO functions that did stuff on some state and then test >>> them over long periods of time in GHCi. >>> >>> I was worried I might be depending on some guarantees that aren't >>> actually there, like moo being discarded and recreated inbetween invocations >>> of different functions. >>> >> >> Define safe... In this case though, I would guess it's not safe. The >> compiler is free to call moo zero, one or many times depending on its >> evaluation strategy, and when it's demanded. It's possible that your TVar >> will get created many times, and different values returned by the "constant" >> moo. >> >> That sounds pretty unsafe to me. >> >> Bob >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/2efdd175/attachment.htm From lrpalmer at gmail.com Sun Dec 7 21:34:00 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 7 21:27:07 2008 Subject: [Haskell-cafe] Problem with System.Random.randoms In-Reply-To: References: Message-ID: <7ca3f0160812071834o84a2c00v93cc5e055e77f687@mail.gmail.com> 2008/12/7 S. G?nther > Hi, > > I have a small problem with System.Random.randoms. I need a rather > large number of random numbers but the following program consumes a > huge amount of memory. I terminated it when it used up more than 2 Gb: > > module Main where > > import System.Random > > n :: Int > n = maxBound > > main = do > g <- getStdGen > print $ length $ take n $ ((randoms g)::[Int]) I think the problem is that the list spine is being forced, but not the elements, so the generator is becoming a rather massive thunk. This is peculiar to your benchmark, and would probably not occur in practice when you are actually using the random numbers. Try: strictTake 0 _ = [] strictTake n [] = [] strictTake n (x:xs) = x `seq` (x : strictTake (n-1) xs) And use that instead of take. Again, this strictTake is probably not necessary in your actual application, it's just to fix your benchmark. Luke > > > On the other hand using > take n $ [1..] > it runs in constant space. > Am I doing something wrong? Or should I just abandon randoms and use > the more primitive functions in System.Random? > > Thanks in advance > S. G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/f72cb8fd/attachment.htm From newhoggy at gmail.com Sun Dec 7 22:02:07 2008 From: newhoggy at gmail.com (John Ky) Date: Sun Dec 7 21:55:15 2008 Subject: [Haskell-cafe] Is unsafePerformIO safe here? In-Reply-To: <7ca3f0160812071828mcaba85ap83b9a4bd6e2e4aed@mail.gmail.com> References: <7EB52303-2AA7-4CCE-A123-2EBF14260F58@gmail.com> <7ca3f0160812071828mcaba85ap83b9a4bd6e2e4aed@mail.gmail.com> Message-ID: Inline. On Mon, Dec 8, 2008 at 1:28 PM, Luke Palmer wrote: > 2008/12/7 John Ky > >> Does that mean there is no place to store state while running the >> interpreter and that I have to put the state elsewhere such as a file? I >> was hoping to avoid that as I'm only prototyping at this stage and don't >> want to write a persistent layer just yet. > > > Bob is right, that technically it is unsafe. However, in GHC (I can't > speak for the others) you can make it safe by forcing it not to inline. > Then, IIRC, you are guaranteed (only in GHC, not in Haskell) that it will > be only created once: > > moo :: TVar Int > {-# NOINLINE moo #-} > moo = unsafePerformIO $ newTVarIO 1 > Will keep that in mind. > Correct, you cannot have global state in safe Haskell. Make of that what > you will, YMMV, personally I like it (it has positive implications in terms > of semantics and reasoning). You have to put state elsewhere, but "such as > a file" is a little extreme. Make it at the GHCi prompt (if there is more > than a teeny bit of initialization, I usually define a helper function to > make this as easy as possible). > You mean like this? Prelude> x <- GHC.Conc.atomically (GHC.Conc.newTVar 1) Prelude> GHC.Conc.atomically $ GHC.Conc.readTVar x 1 I could live with that. Then pass it around or put your computation in a ReaderT (same thing). > You're going to be passing it around when you write your real application > anyway, right? > Will need to read up on ReaderT. Thanks for the tip. Also, as your application matures, you know your persistence layer is > probably already done for you in Data.Binary :-) > Awesome. Thanks -John > Luke > > >> >> Thanks >> >> -John >> >> >> On Mon, Dec 8, 2008 at 11:51 AM, Thomas Davie wrote: >> >>> >>> On 8 Dec 2008, at 01:28, John Ky wrote: >>> >>> Hi, >>>> >>>> Is the following safe? >>>> >>>> moo :: TVar Int >>>> moo = unsafePerformIO $ newTVarIO 1 >>>> >>>> I'm interested in writing a stateful application, and I wanted to start >>>> with writing some IO functions that did stuff on some state and then test >>>> them over long periods of time in GHCi. >>>> >>>> I was worried I might be depending on some guarantees that aren't >>>> actually there, like moo being discarded and recreated inbetween invocations >>>> of different functions. >>>> >>> >>> Define safe... In this case though, I would guess it's not safe. The >>> compiler is free to call moo zero, one or many times depending on its >>> evaluation strategy, and when it's demanded. It's possible that your TVar >>> will get created many times, and different values returned by the "constant" >>> moo. >>> >>> That sounds pretty unsafe to me. >>> >>> Bob >>> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/4652aa83/attachment.htm From haskell at brecknell.org Sun Dec 7 22:00:28 2008 From: haskell at brecknell.org (Matthew Brecknell) Date: Sun Dec 7 22:22:25 2008 Subject: [Haskell-cafe] Is unsafePerformIO safe here? In-Reply-To: References: <7EB52303-2AA7-4CCE-A123-2EBF14260F58@gmail.com> Message-ID: <1228705228.29264.1288788805@webmail.messagingengine.com> John Ky said: > Does that mean there is no place to store state while running the > interpreter [...]? If all you are doing is experimenting at the GHCi prompt, then maybe this is what you are missing: ...> moo <- newTVarIO 1 ...> :t moo moo :: TVar Integer ...> atomically (readTVar moo) 1 ...> You can also perform "let"-bindings: ...> let incr v = readTVar v >>= writeTVar v . (+1) ...> :t incr incr :: (Num a) => TVar a -> STM () ...> atomically (incr moo) ...> atomically (readTVar moo) 2 ...> For the details, see the GHC reference. From dmehrtash at gmail.com Mon Dec 8 00:49:34 2008 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Mon Dec 8 00:42:43 2008 Subject: [Haskell-cafe] what does "atomically#" mean? Message-ID: Any idea was the atomically# mean in the following code? atomically :: STM a -> IO a atomically (STM m) = IO (\s -> (*atomically# *m) s ) Code is from GHC.Conc module http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081207/42b317a9/attachment.htm From dons at galois.com Mon Dec 8 01:48:23 2008 From: dons at galois.com (Don Stewart) Date: Mon Dec 8 01:41:24 2008 Subject: [Haskell-cafe] what does "atomically#" mean? In-Reply-To: References: Message-ID: <20081208064823.GA32336@scytale.galois.com> dmehrtash: > Any idea was the atomically# mean in the following code? > > atomically :: STM a -> IO a > atomically (STM m) = IO (\s -> (atomically# m) s ) > > Code is from GHC.Conc module > [1]http://www.haskell.org/ghc/docs/6.6/html/libraries/base/GHC-Conc.html It is a primitive hook into the runtime, where transactional memory is implemented. It is documented in the primops module in the GHC source, $ cd ghc/compiler/prelude/ ------------------------------------------------------------------------ section "STM-accessible Mutable Variables" ------------------------------------------------------------------------ primtype TVar# s a primop AtomicallyOp "atomically#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #) ) -> State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True primop RetryOp "retry#" GenPrimOp State# RealWorld -> (# State# RealWorld, a #) with out_of_line = True has_side_effects = True Along with other primitives like: ------------------------------------------------------------------------ section "Parallelism" ------------------------------------------------------------------------ primop ParOp "par#" GenPrimOp a -> Int# with -- Note that Par is lazy to avoid that the sparked thing -- gets evaluted strictly, which it should *not* be has_side_effects = True -- Don From ndmitchell at gmail.com Mon Dec 8 03:29:03 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Dec 8 03:22:09 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: <404396ef0812080029h694660beue3fad0d6fb343bbe@mail.gmail.com> Hi Niklas, > Apart from this, HSE now also parses any unrecognized pragma in option > (e.g. LANGUAGE), declaration (e.g. RULES) or expression (e.g. SCC) > position, allowing user-customized pragmas. Unrecognized pragmas in > other positions will (unfortunately) give a parse error. If this ever > means a problem for you - let me know! This is likely to be a problem for me :-) I certainly have OPTIONS_DERIVE and CATCH pragmas that I've inserted into various programs over time. I think failing on an unrecognised pragma is probably a bad idea, when ignoring a pragma is usually perfectly safe. Thanks Neil From martin.hofmann at uni-bamberg.de Mon Dec 8 04:04:06 2008 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Mon Dec 8 03:54:28 2008 Subject: [Haskell-cafe] Why does "instance Ord Pat" causes <> Message-ID: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> I am storing the TH data types 'Exp' and 'Pat' in Maps and Sets. As a first attempt to quickly get rid of typechecker's complaints I defined some naive instances of Ord for Exp and Pat. Now it took me about a week to realise, that 'instance Ord Pat' causes ghc to loop. Apparently, there is a reason, why Pat and Exp are not instances of Ord. What is so bad about it? If Pat and Exp should not be instances of Ord, maybe a note in the source code or haddock would be helpful. On the other hand, what would argue against a lexicographic ordering (apart from the inefficient implementation of the following one)? Following some literate code to reproduce the <> (or stack overflow in GHCi), by commenting and uncommenting the appropriate lines: > {-# OPTIONS_GHC -fglasgow-exts -fth #-} > module Test where > import Language.Haskell.TH > import Data.Set ------------------- naive Ord > instance Ord Exp > instance Ord Pat ------------------- lexicographic Ord instance Ord Exp where compare l r = compare (show l) (show r) instance Ord Pat where compare l r = compare (show l) (show r) ------------------- > mkVP s = VarP $ mkName s > mkVE s = VarE $ mkName s > rule1 = (,) [mkVP "x_14"] (mkVE "y_14") > rule2 = (,) [InfixP (mkVP "x1_15") '(:) (mkVP "x_16")] (InfixE (Just (mkVE "y1_15")) (ConE '(:)) (Just (mkVE "ys_16"))) > stack_overflow = fromList [rule1,rule2] Thanks, Martin From lrpalmer at gmail.com Mon Dec 8 04:07:28 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Dec 8 04:00:35 2008 Subject: [Haskell-cafe] Why does "instance Ord Pat" causes <> In-Reply-To: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <7ca3f0160812080107t3222af16pca59dab0e0662b02@mail.gmail.com> On Mon, Dec 8, 2008 at 2:04 AM, Martin Hofmann < martin.hofmann@uni-bamberg.de> wrote: > I am storing the TH data types 'Exp' and 'Pat' in Maps and Sets. As a > first attempt to quickly get rid of typechecker's complaints I defined > some naive instances of Ord for Exp and Pat. > > Now it took me about a week to realise, that 'instance Ord Pat' causes > ghc to loop. Apparently, there is a reason, why Pat and Exp are not > instances of Ord. What is so bad about it? > > If Pat and Exp should not be instances of Ord, maybe a note in the > source code or haddock would be helpful. On the other hand, what would > argue against a lexicographic ordering (apart from the inefficient > implementation of the following one)? > > Following some literate code to reproduce the <> (or stack > overflow in GHCi), by commenting and uncommenting the appropriate lines: Try this: data Foo = Foo deriving Eq instance Ord Foo Then try Foo < Foo. instance Ord Foo is not the same as "deriving Ord"; it declares an instance using all default definitions, which are self-referential. It would be nice if typeclass authors could somehow declare the minimal complete definition, so we could get a warning in this case. Luke > > > > > > {-# OPTIONS_GHC -fglasgow-exts -fth #-} > > module Test where > > import Language.Haskell.TH > > import Data.Set > > > ------------------- > naive Ord > > > instance Ord Exp > > > instance Ord Pat > > ------------------- > lexicographic Ord > > instance Ord Exp where > compare l r = compare (show l) (show r) > > instance Ord Pat where > compare l r = compare (show l) (show r) > > ------------------- > > > > mkVP s = VarP $ mkName s > > mkVE s = VarE $ mkName s > > rule1 = (,) [mkVP "x_14"] (mkVE "y_14") > > rule2 = (,) [InfixP (mkVP "x1_15") '(:) (mkVP "x_16")] (InfixE (Just > (mkVE "y1_15")) (ConE '(:)) (Just (mkVE "ys_16"))) > > > stack_overflow = fromList [rule1,rule2] > > > Thanks, > > Martin > > > _______________________________________________ > 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/20081208/9c366d88/attachment.htm From lrpalmer at gmail.com Mon Dec 8 04:13:27 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Dec 8 04:06:37 2008 Subject: [Haskell-cafe] Why does "instance Ord Pat" causes <> In-Reply-To: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <7ca3f0160812080113r3a08d2c5x6facdbfd3c506e5c@mail.gmail.com> On Mon, Dec 8, 2008 at 2:04 AM, Martin Hofmann < martin.hofmann@uni-bamberg.de> wrote: > I am storing the TH data types 'Exp' and 'Pat' in Maps and Sets. As a > first attempt to quickly get rid of typechecker's complaints I defined > some naive instances of Ord for Exp and Pat. > > Now it took me about a week to realise, that 'instance Ord Pat' causes > ghc to loop. Apparently, there is a reason, why Pat and Exp are not > instances of Ord. What is so bad about it? Oh, to answer this, my guess is that such an instance is just kind of silly. It is a meaningless, arbitrary ordering, and is brittle to splitting/combining cases. To put them in sets and maps, go ahead an define an arbitrary ordering however you can, but wrap it in a newtype like this: newtype OrdExp = OrdExp Exp instance Ord OrdExp where compare (OrdExp a) (OrdExp b) = compare (show a) (show b) An orphan instance is one which is defined in a module where neither the class nor the type being instantiated is defined. This newtype wrapping avoids orphan instances, and associates the arbitrary ordering to your own wrapper so if somebody else defined a different arbitrary ordering, they won't conflict. Orphan instances (almost?) always indicate a nonmodular design decision. Luke > > > If Pat and Exp should not be instances of Ord, maybe a note in the > source code or haddock would be helpful. On the other hand, what would > argue against a lexicographic ordering (apart from the inefficient > implementation of the following one)? > > Following some literate code to reproduce the <> (or stack > overflow in GHCi), by commenting and uncommenting the appropriate lines: > > > > > {-# OPTIONS_GHC -fglasgow-exts -fth #-} > > module Test where > > import Language.Haskell.TH > > import Data.Set > > > ------------------- > naive Ord > > > instance Ord Exp > > > instance Ord Pat > > ------------------- > lexicographic Ord > > instance Ord Exp where > compare l r = compare (show l) (show r) > > instance Ord Pat where > compare l r = compare (show l) (show r) > > ------------------- > > > > mkVP s = VarP $ mkName s > > mkVE s = VarE $ mkName s > > rule1 = (,) [mkVP "x_14"] (mkVE "y_14") > > rule2 = (,) [InfixP (mkVP "x1_15") '(:) (mkVP "x_16")] (InfixE (Just > (mkVE "y1_15")) (ConE '(:)) (Just (mkVE "ys_16"))) > > > stack_overflow = fromList [rule1,rule2] > > > Thanks, > > Martin > > > _______________________________________________ > 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/20081208/cd29c883/attachment-0001.htm From bulat.ziganshin at gmail.com Mon Dec 8 04:20:10 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Dec 8 04:13:29 2008 Subject: [Haskell-cafe] Why does "instance Ord Pat" causes <> In-Reply-To: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <671348720.20081208122010@gmail.com> Hello Martin, Monday, December 8, 2008, 12:04:06 PM, you wrote: > Now it took me about a week to realise, that 'instance Ord Pat' causes > ghc to loop. > naive Ord > >> instance Ord Exp >> instance Ord Pat i think you just don't learned this part of Haskell. empty instance declarations like these are possible but they doesn't mean automatic definition of some suitable compare. they just bring in some default definitions which may be mutual recursive, such as (==) and (/=) definitions in Eq class. this is intended to that your define either (==) or (/=), but compiler doesn't check this, so if you don't define anything, you will get endless loop if you want compiler to infer automatic instance definitions, the only way is to use GHC extension, smth like deriving instance Ord for Pat -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From martin.hofmann at uni-bamberg.de Mon Dec 8 04:29:19 2008 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Mon Dec 8 04:19:41 2008 Subject: [Haskell-cafe] Why does "instance Ord Pat" causes <> In-Reply-To: <671348720.20081208122010@gmail.com> References: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> <671348720.20081208122010@gmail.com> Message-ID: <1228728559.6092.18.camel@ios.cogsys.wiai.uni-bamberg.de> Thanks a lot for the quick replies. Indeed that was not clear to me. Cheers, Martin From roma at ro-che.info Mon Dec 8 04:37:25 2008 From: roma at ro-che.info (Roman Cheplyaka) Date: Mon Dec 8 04:31:09 2008 Subject: [Haskell-cafe] Pragmas (was: ANNOUNCE: haskell-src-exts 0.4.4) In-Reply-To: <404396ef0812080029h694660beue3fad0d6fb343bbe@mail.gmail.com> References: <404396ef0812080029h694660beue3fad0d6fb343bbe@mail.gmail.com> Message-ID: <20081208093725.GA27460@flit> * Neil Mitchell [2008-12-08 08:29:03+0000] > > Apart from this, HSE now also parses any unrecognized pragma in option > > (e.g. LANGUAGE), declaration (e.g. RULES) or expression (e.g. SCC) > > position, allowing user-customized pragmas. Unrecognized pragmas in > > other positions will (unfortunately) give a parse error. If this ever > > means a problem for you - let me know! > > This is likely to be a problem for me :-) > > I certainly have OPTIONS_DERIVE and CATCH pragmas that I've inserted > into various programs over time. I think failing on an unrecognised > pragma is probably a bad idea, when ignoring a pragma is usually > perfectly safe. Even more, An implementation is not required to respect any pragma, but the pragma should be ignored if an implementation is not prepared to handle it.[1] Related question: why does not Language.Haskell.Syntax[2] (from haskell-src) represent comments or pragmas in any way? 1. http://www.haskell.org/onlinereport/pragmas.html 2. http://www.haskell.org/ghc/docs/latest/html/libraries/haskell-src/Language-Haskell-Syntax.html -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From twd2 at dockerz.net Mon Dec 8 05:59:09 2008 From: twd2 at dockerz.net (Tim Docker) Date: Mon Dec 8 05:52:41 2008 Subject: [Haskell-cafe] Animated line art In-Reply-To: <493981CA.3050209@btinternet.com> References: <49385178.2040207@btinternet.com> <9A015D433594EA478964C5B34AF3179B027987CA@ntsydexm06.pc.internal.macquarie.com> <493981CA.3050209@btinternet.com> Message-ID: <0BFC0D06-75B0-4BD7-A32E-9021C66AF681@dockerz.net> On 06/12/2008, at 6:32 AM, Andrew Coppin wrote: > Tim Docker wrote: >> If you implement your drawing logic as a >> function from time to the appropriate render actions, ie >> >> | import qualified Graphics.Rendering.Cairo as C >> | | type Animation = Time -> C.Render () >> >> then you just need to call this function multiple times to generate >> sucessive frames. >> > > That was my initial idea... but I'm not sure how well it would > work. I want to do stuff like fade elements in and out, move > complex structures around on the screen, etc. I think it might end > up being a little tangled if I go with this approach. I might be > wrong though... This model of animation as "a function of time to a picture" is probably described in many places. I first saw it described in Paul Hudaks book "The haskell School of Expression: Learning functional programming through multimedia". It shows how primitive animations can be combined in various ways, including overlays and time transformations. You can download the code from the books web-site, which might be of interest even if you can't get hold of a copy of the book. It's intended for pedagogical purposes, rather than a comprehensive animation system, of course. Tim From newhoggy at gmail.com Mon Dec 8 07:03:42 2008 From: newhoggy at gmail.com (John Ky) Date: Mon Dec 8 06:56:49 2008 Subject: [Haskell-cafe] Deriving something else? Message-ID: Hi, I've defined a class and some instances, which I'm hoping would help me "show" values of types that may include transactional elements. class TShow a where tshow :: a -> IO String instance Show (TVar a) where show = "%" instance (Show a) => TShow a where tshow a = return $ show a instance (Show a) => TShow (TVar a) where tshow ta = do a <- readTVar ta return $ show a Having created a new class is it possible to do some magic so that it can be put it into a deriving clause? data Type = Type { field1 :: Int , field2 :: Int } deriving Show data AnotherType = AnotherType { field3 :: Int , field4 :: TVar Type } deriving *TShow* Thanks -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/8fec8768/attachment.htm From voigt at tcs.inf.tu-dresden.de Mon Dec 8 07:16:48 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Mon Dec 8 07:09:53 2008 Subject: [Haskell-cafe] Deriving something else? In-Reply-To: References: Message-ID: <493D1030.5060302@tcs.inf.tu-dresden.de> John Ky wrote: > Having created a new class is it possible to do some magic so that it > can be put it into a deriving clause? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/derive -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From newhoggy at gmail.com Mon Dec 8 07:32:26 2008 From: newhoggy at gmail.com (John Ky) Date: Mon Dec 8 07:25:31 2008 Subject: [Haskell-cafe] Overlapping instances Message-ID: Hi, I've got the following code which tries to implement a TShow class, which is equivalent to Show, except it is supposed to work on TVar types as well. import GHC.Conc createEngine :: String -> Int -> Int -> IO Engine createEngine name major minor = do tUsers <- newTVarIO [] return $ Engine { engineName = name , version = EngineVersion { major = major , minor = minor } , users = tUsers } class TShow a where tshow :: a -> IO String instance Show (TVar a) where show a = "%" instance (Show a) => TShow a where tshow a = return $ show a instance (Show a) => TShow (TVar a) where tshow ta = do a <- atomically (readTVar ta) return $ show a data User = User { userName :: String } deriving Show data EngineVersion = EngineVersion { major :: Int , minor :: Int } deriving Show data Engine = Engine { engineName :: String , version :: EngineVersion , users :: TVar [User] } instance TShow Engine where tshow a = do users <- atomically (readTVar (users a)) return $ "Engine { " ++ "engineName = " ++ show (engineName a) ++ ", " ++ "version = " ++ show (version a) ++ ", " ++ "users = %" ++ show users ++ " }" When I run it however, I get this: *Main> te <- createEngine "Hello" 1 2 *Main> s <- tshow te :1:5: Overlapping instances for TShow Engine arising from a use of `tshow' at :1:5-12 Matching instances: instance (Show a) => TShow a -- Defined at fxmain.hs:(26,0)-(27,27) instance TShow Engine -- Defined at fxmain.hs:(51,0)-(58,41) In a stmt of a 'do' expression: s <- tshow te I'm not seeing how instance (Show a) => TShow a in the above error message is applicable here since Engine is not an instance of Show. Why is it complaining? Thanks, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/4d49e344/attachment.htm From tobias.bexelius at avalanchestudios.se Mon Dec 8 07:43:02 2008 From: tobias.bexelius at avalanchestudios.se (Tobias Bexelius) Date: Mon Dec 8 07:36:10 2008 Subject: [Haskell-cafe] Overlapping instances In-Reply-To: References: Message-ID: <698E8783CC407F4EB0DC9E994B6D4540E1E95C@nut.avalanchestudios.se> The problem is that Engine *could* be made an instance of Show (remember that any user of the module can create that instance later). What you need is the overlappinginstances extension: {-# LANGUAGE OverlappingInstances #-} With this extension, the most specific instance will be used, i.e. "instance TShow Engine" for Enginge's, no matter if it is an instance of Show. /Tobias ________________________________ From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of John Ky Sent: den 8 december 2008 13:32 To: Haskell Cafe Subject: [Haskell-cafe] Overlapping instances Hi, I've got the following code which tries to implement a TShow class, which is equivalent to Show, except it is supposed to work on TVar types as well. import GHC.Conc createEngine :: String -> Int -> Int -> IO Engine createEngine name major minor = do tUsers <- newTVarIO [] return $ Engine { engineName = name , version = EngineVersion { major = major , minor = minor } , users = tUsers } class TShow a where tshow :: a -> IO String instance Show (TVar a) where show a = "%" instance (Show a) => TShow a where tshow a = return $ show a instance (Show a) => TShow (TVar a) where tshow ta = do a <- atomically (readTVar ta) return $ show a data User = User { userName :: String } deriving Show data EngineVersion = EngineVersion { major :: Int , minor :: Int } deriving Show data Engine = Engine { engineName :: String , version :: EngineVersion , users :: TVar [User] } instance TShow Engine where tshow a = do users <- atomically (readTVar (users a)) return $ "Engine { " ++ "engineName = " ++ show (engineName a) ++ ", " ++ "version = " ++ show (version a) ++ ", " ++ "users = %" ++ show users ++ " }" When I run it however, I get this: *Main> te <- createEngine "Hello" 1 2 *Main> s <- tshow te :1:5: Overlapping instances for TShow Engine arising from a use of `tshow' at :1:5-12 Matching instances: instance (Show a) => TShow a -- Defined at fxmain.hs:(26,0)-(27,27) instance TShow Engine -- Defined at fxmain.hs:(51,0)-(58,41) In a stmt of a 'do' expression: s <- tshow te I'm not seeing how instance (Show a) => TShow a in the above error message is applicable here since Engine is not an instance of Show. Why is it complaining? Thanks, -John From briqueabraque at yahoo.com Mon Dec 8 11:27:51 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Mon Dec 8 11:21:07 2008 Subject: [Haskell-cafe] Re: Problem with System.Random.randoms In-Reply-To: References: Message-ID: > Hi, > > I have a small problem with System.Random.randoms. I need a rather > large number of random numbers but the following program consumes a > huge amount of memory. I terminated it when it used up more than 2 Gb: > Interesting. Well, if you don't solve this problem, I recently needed random numbers and it was very clean to use State and StateT to get them updated. Depending on your problem, this may be easier than using a list. Best, Maur?cio From briqueabraque at yahoo.com Mon Dec 8 11:49:22 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Mon Dec 8 11:42:37 2008 Subject: [Haskell-cafe] Cabal: defaultMainNoRead and source file location Message-ID: Hi, I've just seen this from Distribution.ModuleName (ghc 6.10): toFilePath $ ( simple "A.B.C" ) to which ghci answers: "A.B.C". Shouldn't it say "A/B/C"? The reason why I'm asking is that I've just created a Setup.hs with 'defaultMainNoRead', and 'Setup build' complains it can't find A.B.C. When I copy (move doesn't work) C.hs from /A/B to /A.B.C.hs, it doesn't complain, although it fails to generate my library saying: [1 of 1] Compiling A.B.C ( src/A/B/C.hs, dist/build/A/B/C.o) /usr/bin/ar: creating dist/build/libHSabc-0.a /usr/bin/ar: dist/build/A.B.C.o: No such file or directory Thanks for your tips, Maur?cio From monnier at iro.umontreal.ca Mon Dec 8 12:23:32 2008 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Mon Dec 8 12:16:43 2008 Subject: [Haskell-cafe] Re: Dr Dobbs: Time to get good at functional programming References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> Message-ID: > http://www.ddj.com/development-tools/212201710;jsessionid=3MQLTTYJRPL3CQSNDLRSKH0CJUNN2JVN Do they purposefully obfuscate names? I mean who are those "Martin Obersky" and "Don Sype"? Stefan From mpj at cs.pdx.edu Mon Dec 8 12:58:53 2008 From: mpj at cs.pdx.edu (Mark P. Jones) Date: Mon Dec 8 12:51:24 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <20081207044934.GB26889@scytale.galois.com> References: <1228620603.22033.4.camel@porges-laptop> <20081207044934.GB26889@scytale.galois.com> Message-ID: <493D605D.80601@cs.pdx.edu> Don Stewart wrote: > Which suggests that $ was already in the 1.0 report going to SIGPLAN. > Perhaps Paul or Simon could shed light on it? Anyone have the 1.0 report > lying around to check if it was in earlier? As far as Haskell is concerned, the first "report"-ed occurrence of the $ operator was in the Haskell 1.2 report dated March 1992. I don't see any mention of the $ operator in either the 1.0 or the 1.1 reports (April 1990 and August 1991, respectively). The 1.0 report did define the following operator, which is a variant of $: let :: a -> (a -> b) -> b let x k = k x This was exported from the prelude, but its definition actually appeared in the PreludeIO section of the report, hinting at the main motivation for its introduction in support of continuation based I/O. (Monadic I/O didn't officially arrive until the 1.3 report in May 1996.) But the "let" operator was quickly promoted to a keyword in Haskell 1.1 with the introduction of let expressions, replacing the "where expressions" that Haskell 1.0 had provided for local definitions. With the move to 1.1, "where" became part of the syntax for definition right hand sides, able to scope across multiple guards and no longer part of the expression syntax. A little history can sometimes be fun. All the best, Mark From jonathanccast at fastmail.fm Mon Dec 8 13:03:20 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Mon Dec 8 12:56:26 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <493D605D.80601@cs.pdx.edu> References: <1228620603.22033.4.camel@porges-laptop> <20081207044934.GB26889@scytale.galois.com> <493D605D.80601@cs.pdx.edu> Message-ID: <1228759400.5891.16.camel@jcchost> On Mon, 2008-12-08 at 09:58 -0800, Mark P. Jones wrote: > Don Stewart wrote: > > Which suggests that $ was already in the 1.0 report going to SIGPLAN. > > Perhaps Paul or Simon could shed light on it? Anyone have the 1.0 report > > lying around to check if it was in earlier? > > As far as Haskell is concerned, the first "report"-ed occurrence > of the $ operator was in the Haskell 1.2 report dated March 1992. > I don't see any mention of the $ operator in either the 1.0 or > the 1.1 reports (April 1990 and August 1991, respectively). > > The 1.0 report did define the following operator, which is a > variant of $: > > let :: a -> (a -> b) -> b > let x k = k x > > This was exported from the prelude, but its definition actually > appeared in the PreludeIO section of the report, hinting at the > main motivation for its introduction in support of continuation > based I/O. (Monadic I/O didn't officially arrive until the 1.3 > report in May 1996.) Not officially, but `let' as above is in fact the unit of the Cont monad. And (>>>) from the PreludeIO section of the same report is the (>>=) for the Cont monad. So monadic I/O was there, it just seems that no-one noticed (or I haven't seen this explicitly pointed out)... jcc From ryani.spam at gmail.com Mon Dec 8 13:04:00 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Dec 8 12:57:06 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> <200812060032.21681.daniel.is.fischer@web.de> <53396d9e0812061539k1dd299bt456420750bd84e92@mail.gmail.com> <2f9b2d30812070020m52d633c5w1dca7903cdef4768@mail.gmail.com> Message-ID: <2f9b2d30812081004m2ebf9c97qa3a2c223c6dacefc@mail.gmail.com> On Sun, Dec 7, 2008 at 1:51 AM, Fraser Wilson wrote: > (I know you know this, I just have this weird fascination with the showList > wart, although for the life of me I can't think of a better way of doing it) Well, if you extend the compiler's core language with "typecase", you can solve a lot of these problems. Then the implementation of typeclasses changes from "dictionary-passing" to "type-passing", and overlapping instances can be resolved by dynamic dispatch. For example, the following program: class C a where view :: a -> String instance C Char where view x = viewChar x -- primitive instance C String where view x = viewString x -- primitive instance C a => C [a] where view [] = "[]" view (x:xs) = concat $ [ "[", view x ] ++ concatMap (\y -> [ ", ", view y ]) xs ++ [ "]" ] would compile to this "core": view :: Type a -> a -> String view t = typecase t of Char -> viewInstanceChar [t'] -> typecase t' of Char -> viewInstanceString _ -> viewInstanceList t' _ -> error ("no instance for View " ++ show t) viewInstanceChar x = viewChar x viewInstanceString x = viewString x viewInstanceList t x = concat $ [ "[", view t x ] ++ concatMap (\y -> [ ", ", view t y ]) xs ++ [ "]" ] I think at least one Haskell compiler implements typeclasses this way. One nice property of this solution is that you retain parametricity, at least unless you also include "typeof"; any function with a typeclass constraint takes an additional type argument. Passing "Type a" around in this way is like using Typeable in current Haskell except it would have to be supported at the compiler level. And of course all of the standard optimizations apply, so if you statically know that the type is [Char] you inline "view" and get the correct answer. If you statically know that the type is [x] but you don't know x, you can still specialize the case down to just the typecase on the inside of the list. The biggest wart is that "view" is not a total function; the compiler needs to be extra careful to only call it on types that are instances of "View". I wonder if there is a good way to solve this problem? -- ryan From ryani.spam at gmail.com Mon Dec 8 13:19:46 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Dec 8 13:12:53 2008 Subject: [Haskell-cafe] Overlapping instances In-Reply-To: <698E8783CC407F4EB0DC9E994B6D4540E1E95C@nut.avalanchestudios.se> References: <698E8783CC407F4EB0DC9E994B6D4540E1E95C@nut.avalanchestudios.se> Message-ID: <2f9b2d30812081019n356ef6c0td5346cb64c71fa57@mail.gmail.com> On Mon, Dec 8, 2008 at 4:43 AM, Tobias Bexelius wrote: > {-# LANGUAGE OverlappingInstances #-} > > With this extension, the most specific instance will be used, i.e. > "instance TShow Engine" for Engine's, no matter if it is an instance of > Show. Of course, down this way madness lies :) For example, this code: > uhoh :: Show a => a -> IO String > uhoh x = tshow x won't compile. The question is, what should this code do? > instance Show (TVar a) where show _ = "TVAR" > broken :: TVar a -> String > broken x = uhoh x "broken" will construct the Show dictionary for TVars and pass it to "uhoh", which no longer knows that it is getting called on a TVar. Then uhoh will construct a TShow (TVar a) dictionary using the Show (TVar a) dictionary and the instance "Show a => TShow a", even though there is a more specific instance. So the compiler will just not let "uhoh" compile if overlapping is allowed. You can force it to compile using the wrong instance with the "IncoherentInstances" extension, but it's aptly named; the result is bad because each type is supposed to only have one instance for a particular typeclass. It's worse because it breaks referential transparency; if you inline "uhoh" into "broken", now you get the specific instance! -- ryan From dpiponi at gmail.com Mon Dec 8 13:36:08 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Mon Dec 8 13:31:45 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: References: <1228620603.22033.4.camel@porges-laptop> Message-ID: <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> On Sun, Dec 7, 2008 at 2:05 AM, Hans Aberg wrote: > As for the operator itself, it appears in Alonzo Church, "The Calculi of > Lambda-Conversion", where it is written as exponentiation, like x^f That's reminiscent of the notation in Lambek and Scott where (roughly speaking) the function converting an element of an object A^B to an arrow B->A (something Haskellers don't normally have to think about) is written as a superscript integral sign. Presumably this comes from the same source. Both $ and the integral sign are forms of the letter 's'. Don't know why 's' would be chosen though. -- Dan From haberg at math.su.se Mon Dec 8 14:29:30 2008 From: haberg at math.su.se (Hans Aberg) Date: Mon Dec 8 14:22:51 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> Message-ID: On 8 Dec 2008, at 19:36, Dan Piponi wrote: > On Sun, Dec 7, 2008 at 2:05 AM, Hans Aberg wrote: >> As for the operator itself, it appears in Alonzo Church, "The >> Calculi of >> Lambda-Conversion", where it is written as exponentiation, like x^f > > That's reminiscent of the notation in Lambek and Scott where (roughly > speaking) the function converting an element of an object A^B to an > arrow B->A (something Haskellers don't normally have to think about) > is written as a superscript integral sign. Presumably this comes from > the same source. Both $ and the integral sign are forms of the letter > 's'. Don't know why 's' would be chosen though. In set theory, and sometimes in category theory, A^B is just another notation for Hom(B, A), and the latter might be given the alternate notation B -> A. And th reason is that for finite sets, computing cardinalities result in the usual power function of natural numbers - same as Church, then. And the integral sign comes from Leibnitz: a stylized "S" standing for summation. Also, it is common to let "s" or sigma stand for a section, that is, if given functions s: A -> B pi: B -> A such that the composition pi o s: A -> B -> A is the identity on A, then s is called a section and pi a projection (as in differential geometry). Hans From briqueabraque at yahoo.com Mon Dec 8 15:18:50 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Mon Dec 8 15:12:16 2008 Subject: [Haskell-cafe] Re: Cabal: defaultMainNoRead and source file location In-Reply-To: References: Message-ID: > (...) The reason why I'm asking is that I've just created a > Setup.hs with 'defaultMainNoRead', and 'Setup build' complains > it can't find A.B.C. When I copy (move doesn't work) C.hs from > /A/B to /A.B.C.hs, it doesn't complain, > although it fails to generate my library saying: I'm changing to normal defaultMain, but just in case someone wants to check the problem I'm appending a 'darcs whatsnew' over an empty repo. Is this the right place to report that? Does Distribution.Simple or cabal have a bug tracking of its own? Best, Maur?cio addfile ./Setup.hs hunk ./Setup.hs 1 +#!/usr/bin/env runhaskell + +module Main (main) where { import Distribution.Simple ; import +Distribution.PackageDescription ; import Distribution.ModuleName +hiding ( main ) ; import Distribution.PackageDescription.Check ; + + main = defaultMainNoRead pkg ; + + pkg :: PackageDescription ; + + oneLineSynopsis = + "bla ble bli" ; + + longDescription = "\ + \blabla bleble blibli\ + \" ; + + modules = map simple [ "A.B.C" ] ; + + pkg = emptyPackageDescription { + package = PackageIdentifier { + pkgName = PackageName "abc" , + pkgVersion = Version { + versionBranch = [0] , + versionTags = [ "" ] + } + } , + license = PublicDomain , + maintainer = "Me" , + author = "Me" , + synopsis = oneLineSynopsis , + description = longDescription , + category = "any" , + buildDepends = [ Dependency ( PackageName "base" ) AnyVersion ] , + descCabalVersion = orLaterVersion $ Version { + versionBranch = [ 1 , 2 ] , + versionTags = [ "" ] + } , + buildType = Just Custom , + library = Just ( Library { + exposedModules = modules , + libExposed = True , + libBuildInfo = emptyBuildInfo { + hsSourceDirs = [ "./src" ] , + extensions = [ ] + } + } ) + } + +} adddir ./src adddir ./src/A addfile ./src/A.B.C.hs hunk ./src/A.B.C.hs 1 +module A.B.C where { + + a = "asdf" ; + + b = "qwer" ; + + c = "zxcv" + +} adddir ./src/A/B addfile ./src/A/B/C.hs hunk ./src/A/B/C.hs 1 +module A.B.C where { + + a = "asdf" ; + + b = "qwer" ; + + c = "zxcv" + +} From nbloomf at gmail.com Mon Dec 8 16:59:35 2008 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Mon Dec 8 16:52:41 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> Message-ID: <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> > > >> In set theory, and sometimes in category theory, A^B is just another > notation for Hom(B, A), and the latter might be given the alternate notation > B -> A. And th reason is that for finite sets, computing cardinalities > result in the usual power function of natural numbers - same as Church, > then. > > Hans Slightly off topic, but the A^B notation for hom-sets also makes the natural isomorphism we call currying expressable as A^(BxC) = (A^B)^C. Nathan Bloomfield -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/e2d5a14b/attachment.htm From mail at joachim-breitner.de Mon Dec 8 17:15:53 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Mon Dec 8 17:09:03 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> Message-ID: <1228774553.8548.22.camel@otto.ehbuehl.net> Hi, Am Montag, den 08.12.2008, 15:59 -0600 schrieb Nathan Bloomfield: > Slightly off topic, but the A^B notation for hom-sets also makes the > natural isomorphism we call currying expressable as A^(BxC) = (A^B)^C. So A^(B+C) = A^B ? A^C ? Oh, right, I guess that?s actually true: uncurry either :: (a -> c, b -> c) -> (Either a b -> c) (\f -> (f . Left, f . Right)) :: (Either a b -> c) -> (a -> c, b -> c) It?s always nice to see that I havn?t learned the elementary power calculation rules for nothing :-) Greetings, Joachim PS: For those who prefer Control.Arrow to points: (.Left) &&& (.Right) :: (Either a b -> c) -> (a -> c, b -> c) (found by trial and error :-)) -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/1e447e6d/attachment.bin From nominolo at googlemail.com Mon Dec 8 17:18:51 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Mon Dec 8 17:12:00 2008 Subject: [Haskell-cafe] Re: Dr Dobbs: Time to get good at functional programming In-Reply-To: References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> Message-ID: <916b84820812081418r4dcdd5bfybb7dfcd1eb3501dc@mail.gmail.com> That "article" is an incredibly half-assed job. It reads like a high-school essay, thrown together in a hurry before a 1 hour deadline. Maybe it's a good sign that people think they have to do this, but it really doesn't help anyone who wants to know why FP might be worth learing. 2008/12/8 Stefan Monnier : >> http://www.ddj.com/development-tools/212201710;jsessionid=3MQLTTYJRPL3CQSNDLRSKH0CJUNN2JVN > > Do they purposefully obfuscate names? > I mean who are those "Martin Obersky" and "Don Sype"? > > > Stefan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Push the envelope. Watch it bend. From jason.dusek at gmail.com Mon Dec 8 17:35:25 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Dec 8 17:28:30 2008 Subject: [Haskell-cafe] Re: Dr Dobbs: Time to get good at functional programming In-Reply-To: <916b84820812081418r4dcdd5bfybb7dfcd1eb3501dc@mail.gmail.com> References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com> <916b84820812081418r4dcdd5bfybb7dfcd1eb3501dc@mail.gmail.com> Message-ID: <42784f260812081435y4e47631bgfa6ba329f79a5834@mail.gmail.com> It's just there so you can show your boss it was in Dr. Dobbs, and so your boss can think "Wow, I know what FP is -- thank you, Dr. Dobbs!". For this purpose, the only thing better is if we could somehow get them to mention Microsoft everywhere they mention Haskell. Any actual explaining would just get in the way :) -- _jsn From dpiponi at gmail.com Mon Dec 8 18:10:31 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Mon Dec 8 18:03:37 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <1228774553.8548.22.camel@otto.ehbuehl.net> References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> <1228774553.8548.22.camel@otto.ehbuehl.net> Message-ID: <625b74080812081510h7edbd4bn5e52335667917051@mail.gmail.com> 2008/12/8 Joachim Breitner : > So A^(B+C) = A^B ? A^C ? That's part of the basis for Hinze's paper on memoization: http://www.informatik.uni-bonn.de/~ralf/publications/WGP00b.ps.gz > It's always nice to see that I havn't learned the elementary power > calculation rules for nothing :-) More generally, all of Tarski's "high school algebra" axioms carry over to types. You can see the axioms here: http://math.bu.edu/people/kayeats/papers/saga_paper4.ps That proves type theory is child's play :-) -- Dan From dons at galois.com Mon Dec 8 18:40:11 2008 From: dons at galois.com (Don Stewart) Date: Mon Dec 8 18:33:13 2008 Subject: [Haskell-cafe] Building "plugins" from Hackage In-Reply-To: <49380B86.9060309@gmx.net> References: <49380B86.9060309@gmx.net> Message-ID: <20081208234011.GE2008@scytale.galois.com> solistic: > Hello List, > when I try to install the package "plugins" with cabal i get the following > error. > > cabal: dependencies conflict: ghc-6.8.3 requires Cabal ==1.2.4.0 however > Cabal-1.2.4.0 was excluded because plugins-1.3.1 requires Cabal ==1.4.* > > Is there a way to resolve this? Any ideas? > Rebuild Cabal 1.4, then build plugins. Cheers, Don From claus.reinke at talk21.com Mon Dec 8 19:16:04 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Dec 8 19:09:14 2008 Subject: [Haskell-cafe] Re: Dr Dobbs: Time to get good at functionalprogramming References: <4165d3a70812070713ic28bfa4l6d8784cc3c39d929@mail.gmail.com><916b84820812081418r4dcdd5bfybb7dfcd1eb3501dc@mail.gmail.com> <42784f260812081435y4e47631bgfa6ba329f79a5834@mail.gmail.com> Message-ID: <1C145D71D18B43DBAE1B4107B733D30E@cr3lt> > For this purpose, the only thing better is if we could somehow > get them to mention Microsoft everywhere they mention Haskell. > Any actual explaining would just get in the way :) Doesn't quite work without explaining, because one would have to be very careful not to mis-represent financial support by some as endorsement by the whole; but if one were to ask those who have contributed financially to Haskell development in some form or other for their permissions, one could make quite an interesting little list (not to mention the vastly larger list of people who have contributed their time, efforts, and ideas). There have been occasional discussions of language-specific or FP-in-general industry consortiums. Perhaps the simpler form of "Haskell sponsorship" with mutual bragging rights for haskell.org and sponsor could be a seed corn for such organisations. These days, being associated with FP is no longer something that needs explaining, let alone defending, so sponsors could get something out of their contribution, such as cute little logos, tea-cups and t-shirts (apart from the prime motive of better Haskell;-). Imagine all the students that universities could attract by being a "Haskell campus", not just turning out "Haskell engineers", but "supporting Haskell development" by contributing staff time. Imagine all the competent developers and major customers companies could attract by being a "Haskell sponsor", being actively involved in "Haskell frontline development&research". Imagine all those pretty Haskell logos on all those webpages. oops, wrong universe again;-) Claus PS. Of course, if you do go down that route, your next Haskell job in industry might be representing your company on a committee to decide the internationalization of an XML-based interchange format for unicode lambda characters, with the usual sub-committees for upper-, lower-, and othercase variants, each with at least two spin-off standards representing minority preferences or implementors' we-just-did-it decisions. So be careful what you wish for. From dons at galois.com Mon Dec 8 19:18:25 2008 From: dons at galois.com (Don Stewart) Date: Mon Dec 8 19:11:24 2008 Subject: [Haskell-cafe] Re: Dr Dobbs: Time to get good at functionalprogramming In-Reply-To: <1C145D71D18B43DBAE1B4107B733D30E@cr3lt> References: <42784f260812081435y4e47631bgfa6ba329f79a5834@mail.gmail.com> <1C145D71D18B43DBAE1B4107B733D30E@cr3lt> Message-ID: <20081209001825.GK2008@scytale.galois.com> claus.reinke: > > For this purpose, the only thing better is if we could somehow > > get them to mention Microsoft everywhere they mention Haskell. > > Any actual explaining would just get in the way :) > > Doesn't quite work without explaining, because one would have > to be very careful not to mis-represent financial support by some > as endorsement by the whole; but if one were to ask those who > have contributed financially to Haskell development in some form > or other for their permissions, one could make quite an interesting > little list (not to mention the vastly larger list of people who have > contributed their time, efforts, and ideas). > > There have been occasional discussions of language-specific or > FP-in-general industry consortiums. Perhaps the simpler form > of "Haskell sponsorship" with mutual bragging rights for haskell.org > and sponsor could be a seed corn for such organisations. These > days, being associated with FP is no longer something that needs > explaining, let alone defending, so sponsors could get something > out of their contribution, such as cute little logos, tea-cups and > t-shirts (apart from the prime motive of better Haskell;-). > > Imagine all the students that universities could attract by being a > "Haskell campus", not just turning out "Haskell engineers", but > "supporting Haskell development" by contributing staff time. > Imagine all the competent developers and major customers > companies could attract by being a "Haskell sponsor", being > actively involved in "Haskell frontline development&research". > Imagine all those pretty Haskell logos on all those webpages. I suggest any industrial group interested in an Industrial Haskell Group please contact Andy Adams-Moran at Galois. Things are in the pipeline, and the more participants the better. -- Don From daniel.yokomizo at gmail.com Mon Dec 8 22:05:17 2008 From: daniel.yokomizo at gmail.com (Daniel Yokomizo) Date: Mon Dec 8 21:58:22 2008 Subject: [Haskell-cafe] Reading showables In-Reply-To: References: <910ddf450812070538v1aeb2f39p2264a5936691a699@mail.gmail.com> <1228698513.5976.5.camel@jonathans-macbook> Message-ID: 2008/12/7 John Ky : > Thanks for the clarification. > > They're all the same, as you've explained: > > Prelude> putStrLn $ (show . read) "123" > *** Exception: Prelude.read: no parse > > Prelude> putStrLn $ show $ read "123" > *** Exception: Prelude.read: no parse > > Prelude> putStrLn $ (\x -> show (read x)) "123" > *** Exception: Prelude.read: no parse Luke explained why the Exception is raised, I'll try to explain why this kind of problem happens in general: First two ways that work: Prelude> putStrLn $ (show :: Int -> String) . read $ "123" 123 Prelude> putStrLn $ show . (read :: String -> Int) $ "123" 123 In these examples we explicitly typed either the polymorphic producer (i.e. read) or the producer (i.e. show) so ghci can unify the type variables and figure out what is the right instance of the type class. Generally this happen wherever the type class member has a type variable only to the right of the type (either foo :: a or foo :: Something ->a). This kind of member is polymorphic on the result so the caller must define what it's expecting. "show . read" is saying to ghc both the result of read will define the type and the argument of show will define the type, which is a (kind of) mutually recursive typing issue. > -John Best regards, Daniel Yokomizo From wren at freegeek.org Tue Dec 9 00:04:12 2008 From: wren at freegeek.org (wren ng thornton) Date: Mon Dec 8 23:57:16 2008 Subject: [Haskell-cafe] Why does "instance Ord Pat" causes <> In-Reply-To: <7ca3f0160812080107t3222af16pca59dab0e0662b02@mail.gmail.com> References: <1228727046.6092.14.camel@ios.cogsys.wiai.uni-bamberg.de> <7ca3f0160812080107t3222af16pca59dab0e0662b02@mail.gmail.com> Message-ID: <493DFC4C.6050106@freegeek.org> Luke Palmer wrote: > It would be nice if typeclass authors could somehow declare the minimal > complete definition, so we could get a warning in this case. Or the minimal complete definitions. Since there can be more than one covering set. -- Live well, ~wren From newhoggy at gmail.com Tue Dec 9 03:11:33 2008 From: newhoggy at gmail.com (John Ky) Date: Tue Dec 9 03:04:37 2008 Subject: [Haskell-cafe] Data.Map add only if not exist and return true if added Message-ID: Hi, I'm looking for a function for Data.Map that will insert a new key and value into the map if the key doesn't already exist in the map. When the key already exists, I don't want the value updated in the map. Additionally, I want to know whether the key/value was inserted or not so that I can return that fact as a boolean from my function. I can't work out which function in Data.Map is suitable for this task and I wanted to avoid two lookups. Thanks, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081209/ddf248d9/attachment.htm From arthurvl at cs.uu.nl Tue Dec 9 04:13:52 2008 From: arthurvl at cs.uu.nl (Arthur van Leeuwen) Date: Tue Dec 9 04:06:57 2008 Subject: [Haskell-cafe] Data.Map add only if not exist and return true if added In-Reply-To: References: Message-ID: <41D2FA2A-4219-4625-A571-2A0C620E8FA9@cs.uu.nl> On 9 dec 2008, at 09:11, John Ky wrote: > Hi, > > I'm looking for a function for Data.Map that will insert a new key > and value into the map if the key doesn't already exist in the map. > When the key already exists, I don't want the value updated in the > map. Additionally, I want to know whether the key/value was > inserted or not so that I can return that fact as a boolean from my > function. > > I can't work out which function in Data.Map is suitable for this > task and I wanted to avoid two lookups. Data.Map.insertLookupWithKey (\k n o -> o) should do the trick. The first element of the tuple returned is the Maybe a that is Nothing if no value existed at the given key, the second element is the updated map. With kind regards, Arthur. -- /\ / | arthurvl@cs.uu.nl | Work like you don't need the money /__\ / | A friend is someone with whom | Love like you have never been hurt / \/__ | you can dare to be yourself | Dance like there's nobody watching From wss at Cs.Nott.AC.UK Tue Dec 9 04:36:28 2008 From: wss at Cs.Nott.AC.UK (Wouter Swierstra) Date: Tue Dec 9 04:31:50 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <2f9b2d30812081004m2ebf9c97qa3a2c223c6dacefc@mail.gmail.com> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> <200812060032.21681.daniel.is.fischer@web.de> <53396d9e0812061539k1dd299bt456420750bd84e92@mail.gmail.com> <2f9b2d30812070020m52d633c5w1dca7903cdef4768@mail.gmail.com> <2f9b2d30812081004m2ebf9c97qa3a2c223c6dacefc@mail.gmail.com> Message-ID: <5DBDBF92-27E4-43D3-873B-2A1DD662BF39@cs.nott.ac.uk> > The biggest wart is that "view" is not a total function; the compiler > needs to be extra careful to only call it on types that are instances > of "View". I wonder if there is a good way to solve this problem? The usual way to solve this is to define a data type corresponding to all the types in your class. For example: data Data a where | CHAR : Data Char | STRING : Data String | LIST : Data a -> Data [a] ... With this representation you no longer need typecase (which is horrendous semantic hack) and your dispatch function can be made total. Hope this helps, Wouter This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From ryani.spam at gmail.com Tue Dec 9 06:09:56 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Dec 9 06:02:59 2008 Subject: [Haskell-cafe] How to define Show [MyType] ? In-Reply-To: <5DBDBF92-27E4-43D3-873B-2A1DD662BF39@cs.nott.ac.uk> References: <53396d9e0812041427y5101b08fsd14b223427104f71@mail.gmail.com> <493859E0.1030702@van.steenbergen.nl> <53396d9e0812051513j1575d775m5cab7b9b16ed0b42@mail.gmail.com> <200812060032.21681.daniel.is.fischer@web.de> <53396d9e0812061539k1dd299bt456420750bd84e92@mail.gmail.com> <2f9b2d30812070020m52d633c5w1dca7903cdef4768@mail.gmail.com> <2f9b2d30812081004m2ebf9c97qa3a2c223c6dacefc@mail.gmail.com> <5DBDBF92-27E4-43D3-873B-2A1DD662BF39@cs.nott.ac.uk> Message-ID: <2f9b2d30812090309x1f384a0di733c09ceac772a03@mail.gmail.com> Interesting. But from a practical point of view (I know, irrelevant! *grin*), it's very tempting to piggyback the entirety of the typeclass feature on a simple technique like this. It also gives you the benefit that functions like this: > manyConstraints :: (Show a, Eq a, Data a) => a -> Bool end up only taking a single "type" argument, instead of one per class. In addition, when you use types directly you can remove arguments that are determined by FDs: > class Elem c e | c -> e where ... > instance Elem [a] a where ... > toList :: Elem c e => c -> [e] > toList = ... turns into something like > toList :: Type c -> c -> [e] using e = fdElem c > fdElem c = typecase c of > [e] -> e > ... other instances ... (without the dependency, you have to pass both the type of c and e to toList.) -- ryan On Tue, Dec 9, 2008 at 1:36 AM, Wouter Swierstra wrote: >> The biggest wart is that "view" is not a total function; the compiler >> needs to be extra careful to only call it on types that are instances >> of "View". I wonder if there is a good way to solve this problem? > > The usual way to solve this is to define a data type corresponding to all > the types in your class. For example: > > data Data a where > | CHAR : Data Char > | STRING : Data String > | LIST : Data a -> Data [a] > ... > > With this representation you no longer need typecase (which is horrendous > semantic hack) and your dispatch function can be made total. Hope this > helps, > > Wouter > > > > This message has been checked for viruses but the contents of an attachment > may still contain software viruses, which could damage your computer system: > you are advised to perform your own checks. Email communications with the > University of Nottingham may be monitored as permitted by UK legislation. > > From duncan.coutts at worc.ox.ac.uk Tue Dec 9 08:52:50 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 9 08:46:00 2008 Subject: [Haskell-cafe] Cabal: defaultMainNoRead and source file location In-Reply-To: References: Message-ID: <1228830770.10115.414.camel@localhost> On Mon, 2008-12-08 at 14:49 -0200, Mauricio wrote: > Hi, > > I've just seen this from Distribution.ModuleName (ghc 6.10): > > toFilePath $ ( simple "A.B.C" ) > > to which ghci answers: "A.B.C". > > Shouldn't it say "A/B/C"? You're using it wrong. A 'simple' module name should have no '.' in it. Instead use Distribution.Text.simpleParse "A.B.C". I'll change the assertion into a check that runs every time and add another function to construct module names from a list, and check. Duncan From emax at chalmers.se Tue Dec 9 08:54:26 2008 From: emax at chalmers.se (Emil Axelsson) Date: Tue Dec 9 08:47:27 2008 Subject: [Haskell-cafe] Exact parsing of decimal numbers Message-ID: <493E7892.3060301@chalmers.se> Hello, I don't know enough about the RealFrac class to answer this myself: Can I be sure that Numeric.readFloat :: ReadS Rational never exhibits any rounding errors? Thanks, / Emil From duncan.coutts at worc.ox.ac.uk Tue Dec 9 09:18:27 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 9 09:11:34 2008 Subject: [Haskell-cafe] ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: <1228832307.10115.417.camel@localhost> On Thu, 2008-12-04 at 19:04 +0100, Niklas Broberg wrote: > Fellow Haskelleers, > > it is my pleasure to announce the new release of the haskell-src-exts > package, version 0.4.4: So when will we simply declare that haskell-src-exts is the new haskell-src? :-) That implementation is widely acknowledged to be limited and less than useful. For example it cannot even do the identity transform on Haskell98 programs because it omits brackets in expressions with infix operators. Duncan From lennart at augustsson.net Tue Dec 9 09:25:03 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Dec 9 09:18:05 2008 Subject: [Haskell-cafe] Exact parsing of decimal numbers In-Reply-To: <493E7892.3060301@chalmers.se> References: <493E7892.3060301@chalmers.se> Message-ID: Yes. On Tue, Dec 9, 2008 at 1:54 PM, Emil Axelsson wrote: > Hello, > > I don't know enough about the RealFrac class to answer this myself: > > Can I be sure that > > Numeric.readFloat :: ReadS Rational > > never exhibits any rounding errors? > > Thanks, > > / Emil > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan.coutts at worc.ox.ac.uk Tue Dec 9 09:32:30 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 9 09:25:35 2008 Subject: [Haskell-cafe] Building/installing haskelldb and friends with ghc 6.10.1 In-Reply-To: <709219BA-DF78-49CA-8C25-314A7017D43F@niaow.com> References: <709219BA-DF78-49CA-8C25-314A7017D43F@niaow.com> Message-ID: <1228833150.10115.425.camel@localhost> On Sat, 2008-12-06 at 23:32 +0100, Laurent Giroud wrote: > Hi everyone, > > I have been trying to install haskelldb in the last few days and > encountered a number of hurdles which raised a few questions and for > which I'd appreciate some insight and advice. Note that I am posting > here because they are not specifically haskelldb related. > > I am using Cabal to install haskelldb, haskelldb-hsql, haskelldb-hsql- > mysql (and others) and discovered that the packages available on > hackage do not build properly with ghc 6.10.1. The typical error being > of the following kind: I don't think the haskelldb-* packages have been updated for ghc-6.8. > Other searches in haskell cafe lead me to people advising to use HDBC > instead, after which I contemplated suicide for a few seconds before > coming back to my senses and cabal-installing haskelldb-hdbc which > quickly led me to error messages of the exact same kind mentioned above. > Strangely enough, hdbc 1.1.5 itself installs quite fine using Cabal, > however, haskell-hdbc insists on depending on version 1.0.1. That's because the haskelldb-hdbc depends on exactly HDBC ==1.0.1 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskelldb-hdbc > I haven't been able so far to find what configuration file to modify in order > for it to try to build with the latest Cabalized version (I admit I > didn't search much). If you want to update haskelldb-hdbc then just change the .cabal file to adjust the version constraints on the HDBC package and fix any issues arising from the update (eg api changes). I'm sure the maintainers would appreciate your patches since they seem not to have any time to do the updates themselves. > Pursuing any further would seem to require to delve deeper in the > intricacies of the Cabal system and fix either HSQL or HaskellDB-HDBC. > Since I really want to use HaskellDB I'll probably try these avenues, > but I would appreciate comments at this point from persons > knowledgeable in the evocated areas: > > Are the databases interface for haskelldb still officially maintained > and where is this information available ? I would guess not. The .cabal file lists haskelldb-users@lists.sourceforge.net as the maintainer. You might check the archives for signs of activity or send an email there. > Is the information that this and that package are compatible (or not) > with ghc 6.8.x or 6.10.1 available somewhere without compiling first > hand the packages ? Yes. On the package page it lists build failures for ghc-6.8 and 6.10 > It would be immensely valuable to the haskell newcomer to have the > incompatible packages signaled on > http://hackage.haskell.org/packages/archive/pkg-list.html > for example. I hope we can do that in future. At the moment the build results are not sufficiently reliable to advertise them that prominently. It's also complicated by the fact that packages may build on some platforms and not others. > What would you recommend at this point : fix hsql, or haskelldb-hdbc > so it uses 1.1.5 instead of 1.1, try an alternative to haskelldb (are > there any ?) ? If you need the high level api provided by haskelldb then yes fix it. If not then just use HDBC directly. Duncan From arnarbi at gmail.com Tue Dec 9 09:48:37 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Tue Dec 9 09:41:40 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <625b74080812081510h7edbd4bn5e52335667917051@mail.gmail.com> References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> <1228774553.8548.22.camel@otto.ehbuehl.net> <625b74080812081510h7edbd4bn5e52335667917051@mail.gmail.com> Message-ID: <28012bc60812090648p65353262v5b78a33b123a9e01@mail.gmail.com> On Mon, Dec 8, 2008 at 23:10, Dan Piponi wrote: > More generally, all of Tarski's "high school algebra" axioms carry > over to types. You can see the axioms here: > http://math.bu.edu/people/kayeats/papers/saga_paper4.ps That proves > type theory is child's play :-) Ah, the power of a well chosen notation :) As for the original question, this message: http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/msg00675.html suggests that the application operator was suggested by Kent Karlsson, but I couldn't find the actual suggestion though. cheers, Arnar From ry at tinyclouds.org Tue Dec 9 11:07:01 2008 From: ry at tinyclouds.org (ryah dahl) Date: Tue Dec 9 11:00:05 2008 Subject: [Haskell-cafe] Timber mailing list Message-ID: <3ae7f4480812090807i734b05ecqd8a8ba9ab46489ce@mail.gmail.com> Is there a user mailing list for the Timber language? (http://www.timber-lang.org/) From mailing_list at istitutocolli.org Tue Dec 9 12:07:25 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Tue Dec 9 12:00:30 2008 Subject: [Haskell-cafe] FFI, TH or GHCI, foreign bindings and the linker(s) In-Reply-To: <20081207180828.GA26345@Andrea.Nowhere.net> References: <20081207180828.GA26345@Andrea.Nowhere.net> Message-ID: <20081209170725.GI22600@Andrea.Nowhere.net> For later reference: I created a minimal test case to illustrate the issue and moved to the (hopefully) more appropriate glasgow-haskell-users list: http://www.haskell.org/pipermail/glasgow-haskell-users/2008-December/016312.html cheers, andrea On Sun, Dec 07, 2008 at 07:08:28PM +0100, Andrea Rossato wrote: > Hello, > > I know that this is somehow a recurring question, still the archives > have not been helpful for finding a working solution. From agocorona at gmail.com Tue Dec 9 16:26:17 2008 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue Dec 9 16:19:26 2008 Subject: [Haskell-cafe] Re: problems with hs-plugins load-eval (possible bug) Message-ID: The duplicate definition error appears when I compile Main.hs and execute it. But when I run it with runghc the behaviour is different. It works well: > runghc Main.hs 3 Any idea? is this a bug of hs-plugins? it is just something expected?? 2008/12/6 Alberto G. Corona > I have a web server which load server extensions. these extensions > eval-uate configuration files that contains code (user-editable workflow > descriptions). The problem is that I need common definitions (inside > imported modules) for the extensions and for the configuration files. This > is not permitted by ha-plugins. > > The minimal code example are the files below. main loads eval.hs , that > evaluate a expression. The common definitions are in Include.hs. The error > is: > > *GHCi runtime linker: fatal error: I found a duplicate definition for > symbol > Include_sum1_srt > whilst processing object file > /home/magocoal/haskell/devel/votesWorkflow/src/unused/tests/Include.o > > This could be caused by: > * Loading two different object files which export the same symbol > * Specifying the same object file twice on the GHCi command line > * An incorrect `package.conf' entry, causing some object to be > loaded twice. > GHCi cannot safely continue in this situation. Exiting now. Sorry. > * > > > ** > Do you kno how to solve the problem while maintaining the functionality? > > -------Include.hs------- > module Include where > > sum [x,y]= x+y > > > ------Main.hs----- > module Main > where > > import Include > import System.Plugins > > main= do > s <-loadExec "eval.o" "mainc" > print s > > loadExec:: String-> String->IO String > loadExec file method = do > > mv <- load file ["."] [] method > case mv of > LoadSuccess mod v -> v :: IO String > LoadFailure msg -> return $ concat msg > > > > ------------Eval.hs-------- > > module Eval(mainc) where > import System.IO.Unsafe > import System.Eval.Haskell > > mainc= do i <- unsafeEval_ "sum1 [1,2]" ["Include"] [] []["."] :: IO > (Either [String] Int) > return $ show i > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081209/019567ba/attachment.htm From haberg at math.su.se Tue Dec 9 16:38:24 2008 From: haberg at math.su.se (Hans Aberg) Date: Tue Dec 9 16:31:32 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <1228774553.8548.22.camel@otto.ehbuehl.net> References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> <1228774553.8548.22.camel@otto.ehbuehl.net> Message-ID: <6E31D482-923D-49BA-964C-90ED7D0B6A7D@math.su.se> On 8 Dec 2008, at 23:15, Joachim Breitner wrote: > Am Montag, den 08.12.2008, 15:59 -0600 schrieb Nathan Bloomfield: > >> Slightly off topic, but the A^B notation for hom-sets also makes the >> natural isomorphism we call currying expressable as A^(BxC) = (A^B) >> ^C. > > So A^(B+C) = A^B ? A^C ? > > Oh, right, I guess that?s actually true:... I posted some of those relations for lambda-calculus two days ago (this thread). It is so very off-topic, because one can reverse the process, take those operators and some relations, and show it contains the lambda- calculus (or so I remember, don't recall details). Then one problem is that these operators are not so intuitive for all practical purposes. Hans From wasserman.louis at gmail.com Tue Dec 9 17:29:21 2008 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Tue Dec 9 17:22:23 2008 Subject: [Haskell-cafe] scanr producer? Message-ID: Is there a change in strictness with the following transformation? It seems like scanr should be a good consumer and a good producer, intuitively. scanrFB :: (a -> b -> b) -> b -> [a] -> (b -> c -> c) -> c -> c scanrFB f x ls c n = snd (foldr (\ x (b, bs) -> let b' = f x b in (b', b' `c` bs)) (x, n) ls) {-# RULES "scanr" [~1] forall f x l . scanr f x l = build (scanrFB f x l); -# RULES} -- Louis Wasserman wasserman.louis@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081209/e70880b0/attachment.htm From jason.dusek at gmail.com Tue Dec 9 19:22:13 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Dec 9 19:15:15 2008 Subject: [Haskell-cafe] a haskell_proposals subreddit Message-ID: <42784f260812091622o7700063ey1387ea19fd258e75@mail.gmail.com> There is a subreddit for people to propose libraries: http://www.reddit.com/r/haskell_proposals/ The idea being, that Web 2.0 will help us to allocate our collective talents more efficiently when it comes to extensions (and perhaps clue us in when our pet project is something people really want). -- _jsn From niklas.broberg at gmail.com Tue Dec 9 19:30:44 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Tue Dec 9 19:23:44 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: > Are SrcSpan's on the TODO list? Seeing how this is the first I hear of them, I can't say that they have been, but they could be. :-) Could you give me a rundown on what usecases you'd need SrcSpans for, and where HSE currently fails you in this regard? Cheers, /Niklas From niklas.broberg at gmail.com Tue Dec 9 19:46:32 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Tue Dec 9 19:39:34 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: <404396ef0812080029h694660beue3fad0d6fb343bbe@mail.gmail.com> References: <404396ef0812080029h694660beue3fad0d6fb343bbe@mail.gmail.com> Message-ID: >> Apart from this, HSE now also parses any unrecognized pragma in option >> (e.g. LANGUAGE), declaration (e.g. RULES) or expression (e.g. SCC) >> position, allowing user-customized pragmas. Unrecognized pragmas in >> other positions will (unfortunately) give a parse error. If this ever >> means a problem for you - let me know! > > This is likely to be a problem for me :-) > > I certainly have OPTIONS_DERIVE and CATCH pragmas that I've inserted > into various programs over time. Are you sure that would be a problem? Seems to me that OPTIONS_DERIVE would appear in the same position as any other OPTIONS pragma, in which case HSE will handle it just fine. I don't know where CATCH would appear, but intuitively it sounds like something that would appear as an expression (or statement which is really just an expression), in which case HSE will handle it too. It's only pragmas appearing in "surprising" locations that would cause HSE to balk. > I think failing on an unrecognised > pragma is probably a bad idea, when ignoring a pragma is usually > perfectly safe. Well, I have a dilemma here. To ignore a pragma, I need to ignore it at the lexer stage, since once I've passed a lexed token to the parser it needs to be handled in some way, or a parse error ensues. It's not hard to have a set of recognized pragmas that pass the lexer stage, and discard any others as comments. However, I am not fully satisfied with this approach, the reason being that I've had feature requests for HSE to allow for custom, user-defined pragmas. I can't ignore unrecognized pragmas *and* allow custom pragmas. The safe way is obviously to be conservative, but it is also the way that gives the users the least power over pragmas. There is also the option to lex all pragmas, and then pollute the parser so that every primitive could be an unrecognized pragma followed by the actual primitive. That would make it safe in all instances, and user-custom pragmas could be allowed in predefined positions, and discarded by the parser in others. But the cost would be quite high in terms of parser complexity. I could potentially also add the possibility for unknown pragmas to appear in all other positions too - types, patterns etc. But that too would be quite a lot of extra machinery for something that would most likely be used very rarely at best. I'm torn and welcome all input on this matter. Cheers, /Niklas From ml at niaow.com Tue Dec 9 19:48:53 2008 From: ml at niaow.com (Laurent Giroud) Date: Tue Dec 9 19:41:16 2008 Subject: [Haskell-cafe] Building/installing haskelldb and friends with ghc 6.10.1 In-Reply-To: <1228833150.10115.425.camel@localhost> References: <709219BA-DF78-49CA-8C25-314A7017D43F@niaow.com> <1228833150.10115.425.camel@localhost> Message-ID: Hi Duncan, thanks a lot for your answers. >> however, haskell-hdbc insists on depending on version 1.0.1. > > That's because the haskelldb-hdbc depends on exactly HDBC ==1.0.1 > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskelldb-hdbc > >> I haven't been able so far to find what configuration file to >> modify in order >> for it to try to build with the latest Cabalized version (I admit I >> didn't search much). > > If you want to update haskelldb-hdbc then just change the .cabal > file to > adjust the version constraints on the HDBC package and fix any issues > arising from the update (eg api changes). Yes, I finally found that setting and tried to build it against hdbc-1.1.5 : it fails and fixing this code is far above my current capabilities so I wouldn't be able to update it myself yet. This being said, I have found this http://darcs.haskell.org/haskelldb/driver-hdbc/haskelldb-hdbc.cabal which would tend to indicate that someone has already updated haskelldb-hdbc to hdbc 1.1.4+. I assume the person(s) who did these changes has(have) not been able to push them into hackage yet. I'll be trying to work with it. If I can get something out of it, I'll try to contact the last patches authors and discuss pushing that version to hackage. > I'm sure the maintainers would appreciate your patches since they seem > not to have any time to do the updates themselves. I certainly understand that, I will make any patches of mine public as soon as I get something to work. >> Are the databases interface for haskelldb still officially maintained >> and where is this information available ? > > I would guess not. The .cabal file lists > haskelldb-users@lists.sourceforge.net as the maintainer. You might > check > the archives for signs of activity or send an email there. I have subscribed to the list which seems utterly desert, I haven't contacted any past author though yet but will do so. >> Is the information that this and that package are compatible (or not) >> with ghc 6.8.x or 6.10.1 available somewhere without compiling first >> hand the packages ? > > Yes. On the package page it lists build failures for ghc-6.8 and 6.10 Yes, thanks, I noticed that a few minutes after posting my initial mail :) >> What would you recommend at this point : fix hsql, or haskelldb-hdbc >> so it uses 1.1.5 instead of 1.1, try an alternative to haskelldb (are >> there any ?) ? > > If you need the high level api provided by haskelldb then yes fix > it. If > not then just use HDBC directly. I will be trying the aforementioned "updated" version first, if it doesn't work, I'll definitely fix the existing one if that doesn't imply more than newbie level haskell skills. The high level API and type safety provided by haskelldb are the reason why I want to experiment with it. My company has just begun to use the C# Entity Framework which notably allows C# programs to manipulate databases using LINQ constructs, and the comparison with haskelldb will probably be very interesting. I have no doubt that the environment provided by Microsoft is much more advanced and complete than what haskelldb can currently provide, yet I have hope that this will lead people here to at least keep an eye on haskell capabilities. Thanks again for your anwsers ! Regards, Laurent From niklas.broberg at gmail.com Tue Dec 9 19:53:09 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Tue Dec 9 19:46:10 2008 Subject: [Haskell-cafe] ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: <1228832307.10115.417.camel@localhost> References: <1228832307.10115.417.camel@localhost> Message-ID: (CC libraries) > So when will we simply declare that haskell-src-exts is the new > haskell-src? :-) I talked about this with Ross Paterson at one point, and his main objection (which I very much agree with) was that haskell-src-exts doesn't let you *optionally* handle extensions, so in some cases valid H98 programs will be discarded due to syntax stealing (e.g. $x from TH). I've had ideas for how to fix this shortcoming for a long while, but never really had the time to actually implement it. It is still my hope and goal that haskell-src-exts will replace the haskell-src package, when it is ready to do so. What do others think about this? Cheers, /Niklas From briqueabraque at yahoo.com Tue Dec 9 20:21:34 2008 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Tue Dec 9 20:14:45 2008 Subject: [Haskell-cafe] Does ghc use Language.Haskell.*? Message-ID: Hi, I've just coded a small utility to prettyprint my code, based on Language.Haskell.Parser and friends. Much to my surprise it wasn't able to parse itself, complaining about a non-ASC character (?). Why can ghc read the program, but not the standard library parser? Does ghc use something else? Is it possible to use whatever ghc uses to build a prettyprinter? Thanks, Maur?cio From redcom at fedoms.com Tue Dec 9 20:37:35 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Tue Dec 9 20:33:05 2008 Subject: [Haskell-cafe] File name encodings Message-ID: Hi, how can I convert a file name with for example umlauts (?, ? ... ) into UTF8, or some other format that I can actually use it? G?nther -- On a German Win XP From dons at galois.com Tue Dec 9 20:45:04 2008 From: dons at galois.com (Don Stewart) Date: Tue Dec 9 20:38:06 2008 Subject: [Haskell-cafe] File name encodings In-Reply-To: References: Message-ID: <20081210014504.GP5981@scytale.galois.com> redcom: > Hi, > > how can I convert a file name with for example umlauts (?, ? ... ) into > UTF8, or some other format that I can actually use it? > > G?nther > Using the utf8-string package to encode the file name string. e.g. x <- readFile (encode "??? ??????") http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string From allbery at ece.cmu.edu Tue Dec 9 20:58:24 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Dec 9 20:51:30 2008 Subject: [Haskell-cafe] Does ghc use Language.Haskell.*? In-Reply-To: References: Message-ID: <83F5BCB7-8C11-4E75-AA4C-E6BDA9764E04@ece.cmu.edu> On 2008 Dec 9, at 20:21, Maur? cio wrote: > Why can ghc read the program, but not the standard > library parser? Does ghc use something else? > Is it possible to use whatever ghc uses to build > a prettyprinter? Language.Haskell is known to be incomplete. The haskell-src-exts package on http://hackage.haskell.org will be more useful. -- 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 dons at galois.com Tue Dec 9 21:11:34 2008 From: dons at galois.com (Don Stewart) Date: Tue Dec 9 21:04:35 2008 Subject: [Haskell-cafe] File name encodings In-Reply-To: <20081210014504.GP5981@scytale.galois.com> References: <20081210014504.GP5981@scytale.galois.com> Message-ID: <20081210021134.GQ5981@scytale.galois.com> dons: > redcom: > > Hi, > > > > how can I convert a file name with for example umlauts (?, ? ... ) into > > UTF8, or some other format that I can actually use it? > > > > G?nther > > > > Using the utf8-string package to encode the file name string. > > e.g. > > x <- readFile (encode "??? ??????") > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string In fact, utf8-string readFile already encodes the file name, so http://hackage.haskell.org/packages/archive/utf8-string/0.3.3/doc/html/System-IO-UTF8.html#v%3AreadFile should be enough. -- Don From dons at galois.com Tue Dec 9 21:17:54 2008 From: dons at galois.com (Don Stewart) Date: Tue Dec 9 21:10:58 2008 Subject: [Haskell-cafe] File name encodings In-Reply-To: References: <20081210014504.GP5981@scytale.galois.com> Message-ID: <20081210021754.GR5981@scytale.galois.com> Oh, perhaps you want to 'decode' the string that dirOpenDialog returns. redcom: > Hi Don, > > must be doing something wrong. > > The messed up string originates from calling Graphics.UI.WX.dirOpenDialog > and selecting a directory with Umlauts. > > The encode function doesn't seem to help here as it's too far at the end > of the chain. > > G?nther > > Am 10.12.2008, 02:45 Uhr, schrieb Don Stewart : > > >redcom: > >>Hi, > >> > >>how can I convert a file name with for example umlauts (?, ? ... ) into > >>UTF8, or some other format that I can actually use it? > >> > >>G?nther > >> > > > >Using the utf8-string package to encode the file name string. > > > > e.g. > > > > x <- readFile (encode "??? ??????") > > > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string > > From dons at galois.com Tue Dec 9 23:34:20 2008 From: dons at galois.com (Don Stewart) Date: Tue Dec 9 23:27:14 2008 Subject: [Haskell-cafe] Haskell project proposals reddit Message-ID: <20081210043420.GT5981@scytale.galois.com> I'd like to echo Jason's remarks earlier. http://www.reddit.com/r/haskell_proposals/ We've tried for a couple of years now to efficiently track 'wanted libraries' for the community, but never with much success. In particular, two approaches have been tried: * a wiki page * the 200{6,7,8} summer of code trac neither proved workable long term, likely because no one knew about them, they're harder to contribute to and other factors. Now I know there's a lot of spare Haskell capacity in this community. 3000 mailing list readers, but only 70 new libraries a week being uploaded to Hackage --- that's not how we take over the world! So this is your chance to contribute: * propose new libraries, and explain why you'd want them * vote on things you'd like to see * pick up tasks that sound interesting Let's try to make this work! -- Don From DekuDekuplex at Yahoo.com Wed Dec 10 02:47:49 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Dec 10 02:41:05 2008 Subject: [Haskell-cafe] Re: Haskell project proposals reddit References: <20081210043420.GT5981@scytale.galois.com> Message-ID: On Tue, 9 Dec 2008 20:34:20 -0800, Don Stewart wrote: >I'd like to echo Jason's remarks earlier. > > http://www.reddit.com/r/haskell_proposals/ > >We've tried for a couple of years now to efficiently track 'wanted >libraries' for the community, but never with much success. > >In particular, two approaches have been tried: > > * a wiki page > * the 200{6,7,8} summer of code trac > >neither proved workable long term, likely because no one knew about >them, they're harder to contribute to and other factors. > >Now I know there's a lot of spare Haskell capacity in this community. >3000 mailing list readers, but only 70 new libraries a week being >uploaded to Hackage --- that's not how we take over the world! > >So this is your chance to contribute: > > * propose new libraries, and explain why you'd want them > * vote on things you'd like to see > * pick up tasks that sound interesting > >Let's try to make this work! After just registering and proposing "A library (or "embedded language") for interactive animations with 2D and 3D graphics and sound to replace Fran," thirteen minutes have passed, but my proposal hasn't appeared yet. Is your proposal list at http://www.reddit.com/r/haskell_proposals/ moderated? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From ndmitchell at gmail.com Wed Dec 10 03:51:42 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Dec 10 03:44:44 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: <404396ef0812080029h694660beue3fad0d6fb343bbe@mail.gmail.com> Message-ID: <404396ef0812100051m3fb454c7n6b60d2bf33733200@mail.gmail.com> Hi Niklas, >> I certainly have OPTIONS_DERIVE and CATCH pragmas that I've inserted >> into various programs over time. > > Are you sure that would be a problem? Seems to me that OPTIONS_DERIVE > would appear in the same position as any other OPTIONS pragma, in > which case HSE will handle it just fine. I don't know where CATCH > would appear, but intuitively it sounds like something that would > appear as an expression (or statement which is really just an > expression), in which case HSE will handle it too. > It's only pragmas appearing in "surprising" locations that would cause > HSE to balk. Ah, so its not unrecognised pragmas, but pragmas in unrecognised places? In that case that's fine. The CATCH pragmas go at the statement level, so are fairly standard in terms of placement. Thanks Neil From lemmih at gmail.com Wed Dec 10 04:03:05 2008 From: lemmih at gmail.com (Lemmih) Date: Wed Dec 10 03:56:05 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: On Wed, Dec 10, 2008 at 1:30 AM, Niklas Broberg wrote: >> Are SrcSpan's on the TODO list? > > Seeing how this is the first I hear of them, I can't say that they > have been, but they could be. :-) > > Could you give me a rundown on what usecases you'd need SrcSpans for, > and where HSE currently fails you in this regard? Many editors can find source spans in error messages and highlight the indicated code. Source analysing tools such as HPC or global dead code eliminators often need to annotate the code. These are just the use cases I've personally encountered. I'm sure there are more just waiting to be developed. -- Cheers, Lemmih From wqeqweuqy at hotmail.com Wed Dec 10 04:26:56 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Wed Dec 10 04:20:18 2008 Subject: [Haskell-cafe] Re: Haskell project proposals reddit In-Reply-To: <20081210043420.GT5981@scytale.galois.com> References: <20081210043420.GT5981@scytale.galois.com> Message-ID: Don Stewart wrote: > I'd like to echo Jason's remarks earlier. > > http://www.reddit.com/r/haskell_proposals/ > > We've tried for a couple of years now to efficiently track 'wanted > libraries' for the community, but never with much success. > > In particular, two approaches have been tried: > > * a wiki page > * the 200{6,7,8} summer of code trac > > neither proved workable long term, likely because no one knew about > them, they're harder to contribute to and other factors. > > Now I know there's a lot of spare Haskell capacity in this community. > 3000 mailing list readers, but only 70 new libraries a week being > uploaded to Hackage --- that's not how we take over the world! > > So this is your chance to contribute: > > * propose new libraries, and explain why you'd want them > * vote on things you'd like to see > * pick up tasks that sound interesting > > Let's try to make this work! > > -- Don A library for spatial data structures would be nice (Octree etc). From DekuDekuplex at Yahoo.com Wed Dec 10 04:30:45 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Dec 10 04:23:50 2008 Subject: [Haskell-cafe] Re: a haskell_proposals subreddit References: <42784f260812091622o7700063ey1387ea19fd258e75@mail.gmail.com> Message-ID: On Tue, 9 Dec 2008 16:22:13 -0800, "Jason Dusek" wrote: > There is a subreddit for people to propose libraries: > > http://www.reddit.com/r/haskell_proposals/ > > The idea being, that Web 2.0 will help us to allocate our > collective talents more efficiently when it comes to > extensions (and perhaps clue us in when our pet project is > something people really want). I tried submitting a proposal for "A library (or "embedded language") for interactive animations with 2D and 3D graphics and sound to replace Fran" an hour ago, but it hasn't appeared, while a later proposal has appeared. Do I need to have somebody add me to the list of contributors to participate? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From jason.dusek at gmail.com Wed Dec 10 05:00:26 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Dec 10 04:53:26 2008 Subject: [Haskell-cafe] Re: a haskell_proposals subreddit In-Reply-To: References: <42784f260812091622o7700063ey1387ea19fd258e75@mail.gmail.com> Message-ID: <42784f260812100200x691e7688ve4600bd033dd889@mail.gmail.com> This has happened to some of my proposals, too. The reddit is completely open. -- _jsn From DekuDekuplex at Yahoo.com Wed Dec 10 05:19:53 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Dec 10 05:13:05 2008 Subject: [Haskell-cafe] Re: a haskell_proposals subreddit References: <42784f260812091622o7700063ey1387ea19fd258e75@mail.gmail.com> <42784f260812100200x691e7688ve4600bd033dd889@mail.gmail.com> Message-ID: On Wed, 10 Dec 2008 02:00:26 -0800, "Jason Dusek" wrote: > This has happened to some of my proposals, too. > > The reddit is completely open. That is strange. I just deleted my proposal and resubmitted it, but it still didn't appear. Then I clicked on the up-arrow next to "An ARM port of GHC that works (so we can program the iphone or android) (self.haskell_proposals)", and the number below that arrow increased from 18 to 19, so I tried resetting it by clicking the down-arrow, and the number then decreased back to 17, so I clicked the up-arrow again, and the number increased to 19 again. Is there any way to delete my vote? I submitted it by mistake to see if the REDDIT site was working for me, but even if I log off and back on again, the figure and up-arrow both still display in orange. Since I can't submit my proposal with REDDIT, I'll just have to give up there. -- Benjamin L. Russel -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From briqueabraque at yahoo.com Wed Dec 10 05:33:42 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Wed Dec 10 05:26:52 2008 Subject: [Haskell-cafe] Can my type be allowed as return type in FFI? Message-ID: Hi, When I do: foreign import "nameOfFunction" nameOfFunction :: IO MyType I can get a function that return MyType only if it's a pointer or some of the C* type family. Is it possible to write a new MyType and make it allowed as a return type from foreign functions? Is changing the compiler the only way to do that? Thanks, Maur?cio From ndmitchell at gmail.com Wed Dec 10 05:35:48 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Dec 10 05:28:48 2008 Subject: [Haskell-cafe] Re: a haskell_proposals subreddit In-Reply-To: References: <42784f260812091622o7700063ey1387ea19fd258e75@mail.gmail.com> <42784f260812100200x691e7688ve4600bd033dd889@mail.gmail.com> Message-ID: <404396ef0812100235x1e5df4f3pbaf61f0339de24bc@mail.gmail.com> Hi Clicking up once makes you vote up, clicking up again cancels your up vote. i.e. to cancel an upvote, click up again. Similarly clicking down votes down, clicking again removes your down vote. So therefore clicking up, then down, is (+1) then (-2). Thanks Neil > Then I clicked on the up-arrow next to "An ARM port of GHC that works > (so we can program the iphone or android) (self.haskell_proposals)", > and the number below that arrow increased from 18 to 19, so I tried > resetting it by clicking the down-arrow, and the number then decreased > back to 17, so I clicked the up-arrow again, and the number increased > to 19 again. > > Is there any way to delete my vote? I submitted it by mistake to see > if the REDDIT site was working for me, but even if I log off and back > on again, the figure and up-arrow both still display in orange. > > Since I can't submit my proposal with REDDIT, I'll just have to give > up there. > > -- Benjamin L. Russel > -- > Benjamin L. Russell / DekuDekuplex at Yahoo dot com > http://dekudekuplex.wordpress.com/ > Translator/Interpreter / Mobile: +011 81 80-3603-6725 > "Furuike ya, kawazu tobikomu mizu no oto." > -- Matsuo Basho^ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From DekuDekuplex at Yahoo.com Wed Dec 10 05:47:04 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Dec 10 05:40:12 2008 Subject: [Haskell-cafe] Re: a haskell_proposals subreddit References: <42784f260812091622o7700063ey1387ea19fd258e75@mail.gmail.com> <42784f260812100200x691e7688ve4600bd033dd889@mail.gmail.com> <404396ef0812100235x1e5df4f3pbaf61f0339de24bc@mail.gmail.com> Message-ID: <167vj4tpr3kk0fhe8lman9hfrl6le2lruu@4ax.com> On Wed, 10 Dec 2008 10:35:48 +0000, "Neil Mitchell" wrote: >Hi > >Clicking up once makes you vote up, clicking up again cancels your up >vote. i.e. to cancel an upvote, click up again. Similarly clicking >down votes down, clicking again removes your down vote. So therefore >clicking up, then down, is (+1) then (-2). Indeed! That worked. Thank you! Now to find a way to get REDDIT to post my contributions somehow. Strangely, it lists them separately in my profile, but not in the thread. I don't know how to resolve this. Logging off and back on doesn't help; deleting the original post and reposting it doesn't help, either. Perhaps REDDIT doesn't let users living in a foreign country post? To contribute, the correct procedure is to visit http://www.reddit.com/r/haskell_proposals/, then click on the "Submit a link" sidebar link on the right, and then to fill in the form that appears. Is this correct? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From DekuDekuplex at Yahoo.com Wed Dec 10 06:08:48 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Dec 10 06:01:55 2008 Subject: [Haskell-cafe] Re: a haskell_proposals subreddit References: <42784f260812091622o7700063ey1387ea19fd258e75@mail.gmail.com> <42784f260812100200x691e7688ve4600bd033dd889@mail.gmail.com> <404396ef0812100235x1e5df4f3pbaf61f0339de24bc@mail.gmail.com> <167vj4tpr3kk0fhe8lman9hfrl6le2lruu@4ax.com> Message-ID: On Wed, 10 Dec 2008 19:47:04 +0900, Benjamin L.Russell wrote: >On Wed, 10 Dec 2008 10:35:48 +0000, "Neil Mitchell" > wrote: > >>Hi >> >>Clicking up once makes you vote up, clicking up again cancels your up >>vote. i.e. to cancel an upvote, click up again. Similarly clicking >>down votes down, clicking again removes your down vote. So therefore >>clicking up, then down, is (+1) then (-2). > >Indeed! That worked. Thank you! > >Now to find a way to get REDDIT to post my contributions somehow. >Strangely, it lists them separately in my profile, but not in the >thread. I don't know how to resolve this. Logging off and back on >doesn't help; deleting the original post and reposting it doesn't >help, either. Perhaps REDDIT doesn't let users living in a foreign >country post? > >To contribute, the correct procedure is to visit >http://www.reddit.com/r/haskell_proposals/, then click on the "Submit >a link" sidebar link on the right, and then to fill in the form that >appears. Is this correct? This time, my earlier contribution, which I had already deleted and reposted, appeared with one plus vote, but without my username. Apparently, contributions sometimes appear after a long (about an hour) wait; sometimes they don't (the first time, it didn't appear after even two hours). Since I wanted my username to appear below my contribution, I re-deleted the contribution (including the plus vote along with it), and then reposted it (of course, without the vote). However, now it doesn't appear again. I just hope that whoever voted for my contribution resubmits the vote. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From artyom.shalkhakov at gmail.com Wed Dec 10 06:15:18 2008 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Wed Dec 10 06:08:18 2008 Subject: [Haskell-cafe] Iteratee-based IO and lightweight monadic regions in the wild Message-ID: <2076f2f90812100315n6d891008p4af9037a8fc48308@mail.gmail.com> Hello, Is anybody planning to use these shiny new ways for doing IO? I'm also interested in a fair comparison of ByteString/Binary with iteratee-based IO. Has anybody done this? Regards, Artyom Shalkhakov. From briqueabraque at yahoo.com Wed Dec 10 06:32:11 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Wed Dec 10 06:25:22 2008 Subject: [Haskell-cafe] Re: Does ghc use Language.Haskell.*? In-Reply-To: <83F5BCB7-8C11-4E75-AA4C-E6BDA9764E04@ece.cmu.edu> References: <83F5BCB7-8C11-4E75-AA4C-E6BDA9764E04@ece.cmu.edu> Message-ID: >> Why can ghc read the program, but not the standard >> library parser? Does ghc use something else? >> Is it possible to use whatever ghc uses to build >> a prettyprinter? > > Language.Haskell is known to be incomplete. The haskell-src-exts > package on http://hackage.haskell.org will be more useful. > Haskell-src-exts understands mode features, but I just tried using it and it seems it's also not Unicode aware. Thanks, Maur?cio From duncan.coutts at worc.ox.ac.uk Wed Dec 10 07:25:15 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 10 07:18:16 2008 Subject: [Haskell-cafe] Re: Does ghc use Language.Haskell.*? In-Reply-To: References: <83F5BCB7-8C11-4E75-AA4C-E6BDA9764E04@ece.cmu.edu> Message-ID: <1228911915.10115.476.camel@localhost> On Wed, 2008-12-10 at 09:32 -0200, Mauricio wrote: > >> Why can ghc read the program, but not the standard > >> library parser? Does ghc use something else? > >> Is it possible to use whatever ghc uses to build > >> a prettyprinter? > > > > Language.Haskell is known to be incomplete. The haskell-src-exts > > package on http://hackage.haskell.org will be more useful. > > > > Haskell-src-exts understands mode features, but I > just tried using it and it seems it's also not > Unicode aware. I'm just guessing here but I expect that haskell-src and haskell-src-exts are unicode aware but that you're using something like readFile to read your UTF-8 .hs file. The readFile function (currently) only reads text files in latin-1, not UTF-8. Try using the utf8-string package and the System.IO.UTF8.readFile function instead. Duncan From duncan.coutts at worc.ox.ac.uk Wed Dec 10 07:30:56 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 10 07:23:58 2008 Subject: [Haskell-cafe] Can my type be allowed as return type in FFI? In-Reply-To: References: Message-ID: <1228912256.10115.482.camel@localhost> On Wed, 2008-12-10 at 08:33 -0200, Mauricio wrote: > Hi, > > When I do: > > foreign import "nameOfFunction" nameOfFunction > :: IO MyType > > I can get a function that return MyType only if > it's a pointer or some of the C* type family. Is > it possible to write a new MyType and make it > allowed as a return type from foreign functions? > Is changing the compiler the only way to do that? Of course you're not really returning a MyType but a pointer to one. So use: foreign import "nameOfFunction" nameOfFunction :: IO (Ptr MyType) Using raw Ptrs is not very nice, so we would usually either wrap that in a ForeignPtr or use a Storable instance to get a MyType directly. Which approach to use depends on if you want MyType to have value or reference semantics. If the C type is abstract and you only access it via a pointer then the ForeignPtr approach is sensible. If you directly access all the fields of the C type then using an equivalent Haskell MyType and converting using Storable is the sensible approach. If do recommend reading the FFI spec. It's quite readable and explains a lot of the issues. Getting familiar with the Foreign libraries will help too. The most important bits are understanding ForeignPtr and the Storable class. Duncan From duncan.coutts at worc.ox.ac.uk Wed Dec 10 07:39:00 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 10 07:32:01 2008 Subject: [Haskell-cafe] File name encodings In-Reply-To: <20081210021754.GR5981@scytale.galois.com> References: <20081210014504.GP5981@scytale.galois.com> <20081210021754.GR5981@scytale.galois.com> Message-ID: <1228912740.10115.489.camel@localhost> On Tue, 2008-12-09 at 18:17 -0800, Don Stewart wrote: > Oh, perhaps you want to 'decode' the string that > dirOpenDialog returns. > > redcom: > > Hi Don, > > > > must be doing something wrong. > > > > The messed up string originates from calling Graphics.UI.WX.dirOpenDialog > > and selecting a directory with Umlauts. This is such a huge can of worms. The Gtk open dialog has two functions for returning the selected file name. One returns a string suitable to use with operating system functions like readFile while the other returns a unicode string suitable to display in the user interface. These need not be the same, or even inter-convertible. On Windows they are identical because it uses unicode for file names, however unix uses byte strings and people sometimes use utf8 and sometimes some other locale. So it's not safe to convert a file name to a unicode string and then back again and expect to be saving the same file. Document editor programs typically remember both strings so that it can save the file again even if displaying the file name was lossy (eg due to locale conversion errors like invalid utf8). Yet another reason why FilePath /= String (except on Windows where it does). Duncan From mailing_list at istitutocolli.org Wed Dec 10 07:44:19 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Wed Dec 10 07:37:25 2008 Subject: [Haskell-cafe] Can my type be allowed as return type in FFI? In-Reply-To: <1228912256.10115.482.camel@localhost> References: <1228912256.10115.482.camel@localhost> Message-ID: <20081210124419.GL22600@Andrea.Nowhere.net> On Wed, Dec 10, 2008 at 12:30:56PM +0000, Duncan Coutts wrote: > If do recommend reading the FFI spec. It's quite readable and explains a > lot of the issues. Getting familiar with the Foreign libraries will help > too. The most important bits are understanding ForeignPtr and the > Storable class. I would also add the chapter 17 of Real World Haskell. you can read it here: http://book.realworldhaskell.org/read/interfacing-with-c-the-ffi.html It will guide you through the writing of the bindings to the PCRE library. Very useful and nicely conceived. A good collection of Storable instances that I found very helpful in understanding the subject can be found in the X11 bindings. Hope this helps, Andrea From bulat.ziganshin at gmail.com Wed Dec 10 07:56:24 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Dec 10 07:49:41 2008 Subject: [Haskell-cafe] Translating RWH into other languages Message-ID: <1312601878.20081210155624@gmail.com> Hello Don, There is a team of people which want to translate RWH book into Russian. is it ok? can you help us by establishing "subversion" of RWH book on your site. if it will contain copy of the English book for the beginning and allow team members to further edit it - it will be great! -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From josef.svenningsson at gmail.com Wed Dec 10 08:10:10 2008 From: josef.svenningsson at gmail.com (Josef Svenningsson) Date: Wed Dec 10 08:03:09 2008 Subject: [Haskell-cafe] Haskell project proposals reddit In-Reply-To: <20081210043420.GT5981@scytale.galois.com> References: <20081210043420.GT5981@scytale.galois.com> Message-ID: <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> On Wed, Dec 10, 2008 at 5:34 AM, Don Stewart wrote: > I'd like to echo Jason's remarks earlier. > > http://www.reddit.com/r/haskell_proposals/ > > We've tried for a couple of years now to efficiently track 'wanted > libraries' for the community, but never with much success. > > In particular, two approaches have been tried: > > * a wiki page > * the 200{6,7,8} summer of code trac > > neither proved workable long term, likely because no one knew about > them, they're harder to contribute to and other factors. > I think this is a wonderful initiative, but I can't shake the feeling that reddit is the wrong forum for this. Since reddit is primarily a news site it penalises old submissions and eventually moves them out of the front page. I can't see how that behavior is good for our purposes here. A project proposal that has a thousand upvotes shouldn't be moved from the list just because the proposal itself is old. If we want something that works in the long run we want something like reddit but without the "aging" of old submissions. I don't know of any such thing but there's bound to be one, this being the internet after all. Cheers, Josef From eyal.lotem at gmail.com Wed Dec 10 08:12:21 2008 From: eyal.lotem at gmail.com (Eyal Lotem) Date: Wed Dec 10 08:05:20 2008 Subject: [Haskell-cafe] Associated data types Message-ID: If we have associated type synonyms, is there still reason to have associated data types? For example, we can replace: class C b where data D b ... instance C Int where data D Int = D | E with: class C b where type D b ... data DInt = D | E instance C Int where type D Int = DInt Or perhaps allow, for convenience, this form (which would desugar to the above): class C b where type D b ... instance C Int where data D Int = D | E -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081210/804e828e/attachment.htm From lennart at augustsson.net Wed Dec 10 08:36:11 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Dec 10 08:29:11 2008 Subject: [Haskell-cafe] Associated data types In-Reply-To: References: Message-ID: For an associated data type D, we know that the type function D is injective, i.e., for different indicies given to D we'll get different data types. This makes much more powerful reasoning possible in the type checker. If associated data types are removed there has to be some new mechanism to declare an associated type as injective, or the type system will lose power. -- Lennart 2008/12/10 Eyal Lotem : > If we have associated type synonyms, is there still reason to have > associated data types? > > For example, we can replace: > > class C b where > data D b > ... > > instance C Int where > data D Int = D | E > > with: > > class C b where > type D b > ... > > data DInt = D | E > instance C Int where > type D Int = DInt > > > Or perhaps allow, for convenience, this form (which would desugar to the > above): > > class C b where > type D b > ... > > instance C Int where > data D Int = D | E > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jules at jellybean.co.uk Wed Dec 10 08:40:51 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Wed Dec 10 08:33:56 2008 Subject: [Haskell-cafe] Associated data types In-Reply-To: References: Message-ID: <493FC6E3.5060709@jellybean.co.uk> Lennart Augustsson wrote: > For an associated data type D, we know that the type function D is > injective, i.e., for different indicies given to D we'll get different > data types. This makes much more powerful reasoning possible in the > type checker. If associated data types are removed there has to be > some new mechanism to declare an associated type as injective, or the > type system will lose power. Interesting. Are you able to give an example which exploits this "known distinct types" effect? From lennart at augustsson.net Wed Dec 10 09:09:23 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Dec 10 09:02:22 2008 Subject: [Haskell-cafe] Associated data types In-Reply-To: <493FC6E3.5060709@jellybean.co.uk> References: <493FC6E3.5060709@jellybean.co.uk> Message-ID: Sure. Here's an example. {-# LANGUAGE TypeFamilies #-} module Mail where class C1 a where data T1 a :: * f1 :: T1 a -> T1 a instance C1 Bool where data T1 Bool = A | B deriving Show f1 A = B f1 B = A class C2 a where type T2 a :: * f2 :: T2 a -> T2 a data D2 = C | D deriving Show instance C2 Bool where type T2 Bool = D2 f2 C = D f2 D = C If you try to evaluate (f1 A) it works fine, whereas (f2 C) gives a type error. In fact, the f2 function is impossible to use. -- Lennart On Wed, Dec 10, 2008 at 1:40 PM, Jules Bean wrote: > Lennart Augustsson wrote: >> >> For an associated data type D, we know that the type function D is >> injective, i.e., for different indicies given to D we'll get different >> data types. This makes much more powerful reasoning possible in the >> type checker. If associated data types are removed there has to be >> some new mechanism to declare an associated type as injective, or the >> type system will lose power. > > Interesting. > > Are you able to give an example which exploits this "known distinct types" > effect? > From andres at cs.uu.nl Wed Dec 10 09:17:17 2008 From: andres at cs.uu.nl (Andres Loeh) Date: Wed Dec 10 09:10:17 2008 Subject: [Haskell-cafe] Associated data types In-Reply-To: References: Message-ID: <20081210141717.GO4749@cs.uu.nl> Hi. > Date: Wed, 10 Dec 2008 13:36:11 +0000 > From: Lennart Augustsson > Subject: Re: [Haskell-cafe] Associated data types > > For an associated data type D, we know that the type function D is > injective, i.e., for different indicies given to D we'll get different > data types. This makes much more powerful reasoning possible in the > type checker. If associated data types are removed there has to be > some new mechanism to declare an associated type as injective, or the > type system will lose power. > > -- Lennart > > 2008/12/10 Eyal Lotem : > > If we have associated type synonyms, is there still reason to have > > associated data types? [...] Another, somewhat related, issue is that associated type synonyms cannot currently be partially applied, whereas associated data types can. Cheers, Andres -- Andres Loeh, Universiteit Utrecht mailto:andres@cs.uu.nl mailto:mail@andres-loeh.de http://www.andres-loeh.de From haskell at list.mightyreason.com Wed Dec 10 09:29:44 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Dec 10 09:22:57 2008 Subject: [Haskell-cafe] Re: File name encodings In-Reply-To: <1228912740.10115.489.camel@localhost> References: <20081210014504.GP5981@scytale.galois.com> <20081210021754.GR5981@scytale.galois.com> <1228912740.10115.489.camel@localhost> Message-ID: Duncan Coutts wrote: > Yet another reason why FilePath /= String (except on Windows where it > does). > > Duncan Well, it is not a "OS" issue but a "FileSystem" issue. OS X is a Unix, but the main filesystem is HFS+ which has Unicode names, though they use a different normalization. So "FilePath == String" on most OS X systems. From leather at cs.uu.nl Wed Dec 10 09:30:35 2008 From: leather at cs.uu.nl (Sean Leather) Date: Wed Dec 10 09:23:35 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: References: Message-ID: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> [Responding to an old (but still relevant) thread...] I'm getting this error as well, both in 2.3.0 and 2.4.1. Suppose that I wanted to generate documentation for everything in my Cabal package except for the modules with Template Haskell in them. Is it enough to add {-# OPTIONS_HADDOCK hide #-} to each of these modules? I tried, but it didn't pan out like I hoped. I'm still getting the same error. Is there something else I can do? Thanks, Sean On Tue, Oct 28, 2008 at 01:01, David Waern wrote: > I think this is a bug in Haddock related to template-haskell > declarations. It will hopefully be fixed soon, but I'm afraid it won't > part of the 2.3.0 version that will come with GHC 6.10.1. > > David > > 2008/10/27 Leonidas Fegaras : > > > > Sorry for the previous message. I am sending it again. > > > > Dear fellow haskell programmers, > > I tried to install a package in hackageDB and got a strange error > from > > haddock: > > > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing > > > > Here is the complete log: > > > http://hackage.haskell.org/packages/archive/HXQ/0.10.0/logs/failure/ghc-6.8 > > When I build it using Cabal 1.6.0.1 and haddock 2.2.2 using > 'runhaskell > > Setup.lhs haddock', it works fine (I get warnings but no errors). > > Also haddock 2.3.0 is not available in hackageDB so I can't test > it > > myself. Where I can find haddock 2.3.0? > > > > Thank you for your help, > > Leonidas Fegaras > > > > _________________________________________________________________ > > Stay organized with simple drag and drop from Windows Live Hotmail. > > > http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_102008_______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081210/a933b55e/attachment.htm From lionel at gamr7.com Wed Dec 10 09:18:56 2008 From: lionel at gamr7.com (Lionel Barret De Nazaris) Date: Wed Dec 10 09:24:57 2008 Subject: [Haskell-cafe] Re: Haskell project proposals reddit In-Reply-To: References: <20081210043420.GT5981@scytale.galois.com> Message-ID: <493FCFD0.8020909@gamr7.com> Reddit is not moderated. But there is a difference between the new links and the top links. There you are : http://www.reddit.com/r/haskell_proposals/comments/7ijor/a_library_or_embedded_language_for_interactive/ (upmodded) Benjamin L.Russell wrote: > On Tue, 9 Dec 2008 20:34:20 -0800, Don Stewart > wrote: > > >> I'd like to echo Jason's remarks earlier. >> >> http://www.reddit.com/r/haskell_proposals/ >> >> We've tried for a couple of years now to efficiently track 'wanted >> libraries' for the community, but never with much success. >> >> In particular, two approaches have been tried: >> >> * a wiki page >> * the 200{6,7,8} summer of code trac >> >> neither proved workable long term, likely because no one knew about >> them, they're harder to contribute to and other factors. >> >> Now I know there's a lot of spare Haskell capacity in this community. >> 3000 mailing list readers, but only 70 new libraries a week being >> uploaded to Hackage --- that's not how we take over the world! >> >> So this is your chance to contribute: >> >> * propose new libraries, and explain why you'd want them >> * vote on things you'd like to see >> * pick up tasks that sound interesting >> >> Let's try to make this work! >> > > After just registering and proposing "A library (or "embedded > language") for interactive animations with 2D and 3D graphics and > sound to replace Fran," thirteen minutes have passed, but my proposal > hasn't appeared yet. > > Is your proposal list at http://www.reddit.com/r/haskell_proposals/ > moderated? > > -- Benjamin L. Russell > > > From jefferson.r.heard at gmail.com Wed Dec 10 09:43:34 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Wed Dec 10 09:36:35 2008 Subject: [Haskell-cafe] Re: Haskell project proposals reddit In-Reply-To: References: <20081210043420.GT5981@scytale.galois.com> Message-ID: <4165d3a70812100643s413bfd3ewcb31c1c6874a7a34@mail.gmail.com> I'm working on this now. R-Tree, not Oct-tree, but it'll be there soon. Also working on GDAL/OGR bindings. On Wed, Dec 10, 2008 at 4:26 AM, Neal Alexander wrote: > Don Stewart wrote: >> >> I'd like to echo Jason's remarks earlier. >> >> http://www.reddit.com/r/haskell_proposals/ >> >> We've tried for a couple of years now to efficiently track 'wanted >> libraries' for the community, but never with much success. >> >> In particular, two approaches have been tried: >> >> * a wiki page >> * the 200{6,7,8} summer of code trac >> >> neither proved workable long term, likely because no one knew about >> them, they're harder to contribute to and other factors. >> >> Now I know there's a lot of spare Haskell capacity in this community. >> 3000 mailing list readers, but only 70 new libraries a week being >> uploaded to Hackage --- that's not how we take over the world! >> >> So this is your chance to contribute: >> >> * propose new libraries, and explain why you'd want them >> * vote on things you'd like to see >> * pick up tasks that sound interesting >> >> Let's try to make this work! >> >> -- Don > > A library for spatial data structures would be nice (Octree etc). > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From thomas.dubuisson at gmail.com Wed Dec 10 09:58:29 2008 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Wed Dec 10 09:51:31 2008 Subject: [Haskell-cafe] Haskell project proposals reddit In-Reply-To: <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> References: <20081210043420.GT5981@scytale.galois.com> <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> Message-ID: <4c44d90b0812100658hea3f4b3ob7368db9324cb6f7@mail.gmail.com> On Wed, Dec 10, 2008 at 1:10 PM, Josef Svenningsson < josef.svenningsson@gmail.com> wrote: > On Wed, Dec 10, 2008 at 5:34 AM, Don Stewart wrote: > > I'd like to echo Jason's remarks earlier. > > > > http://www.reddit.com/r/haskell_proposals/ > > > > We've tried for a couple of years now to efficiently track 'wanted > > libraries' for the community, but never with much success. > > > > In particular, two approaches have been tried: > > > > * a wiki page > > * the 200{6,7,8} summer of code trac > > > > neither proved workable long term, likely because no one knew about > > them, they're harder to contribute to and other factors. > > > I think this is a wonderful initiative, but I can't shake the feeling > that reddit is the wrong forum for this. Since reddit is primarily a > news site it penalises old submissions and eventually moves them out > of the front page. I can't see how that behavior is good for our > purposes here. A project proposal that has a thousand upvotes > shouldn't be moved from the list just because the proposal itself is > old. > This isn't entirely true. Just go to "top" items instead of the 'hot' items, which are age-penalized. For example, the DMCA article from one year ago is 2nd on proggit: http://www.reddit.com/r/programming/top/ But I do agree that using reddit is not the right method - under the assumption that its popularity is ever increasing the items on the hot page will naturally collect more votes than older items, and thus even the 'top' page is age-biased. The wiki we already had would be best in my mind, but people just didn't use it despite a couple ML postings about it. If we want something that works in the long run we want something like > reddit but without the "aging" of old submissions. I don't know of any > such thing but there's bound to be one, this being the internet after > all. > > Cheers, > > Josef > _______________________________________________ > 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/20081210/c47f017c/attachment.htm From briqueabraque at yahoo.com Wed Dec 10 11:17:26 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Wed Dec 10 11:10:38 2008 Subject: [Haskell-cafe] Re: Can my type be allowed as return type in FFI? In-Reply-To: <20081210124419.GL22600@Andrea.Nowhere.net> References: <1228912256.10115.482.camel@localhost> <20081210124419.GL22600@Andrea.Nowhere.net> Message-ID: > > > foreign import "nameOfFunction" nameOfFunction > > > :: IO MyType > > > > > Is it possible to write a new MyType and make it allowed as > > > a return type from foreign functions? Is changing the > > > compiler the only way to do that? > > Of course you're not really returning a MyType but a pointer > > to one. (...) This would solve half my problem. Can I always trust that? I've been told before that everytime a C function returns a struct it is actually returning a pointer, but I wasn't able to find that written in stone so that I can trust it to be valid anywhere Haskell will run and for any return type (like a struct containing just a char, for instance). How does that pointer work? My code didn't provide it to the C function, so, I believe I don't have to deallocate it. Where does the memory it points to live? Did Haskell FFI engine gave that pointer to the C function? How much time is it going to live? Enough so I can 'peek' it? > > Using raw Ptrs is not very nice, so we would usually either > > wrap that in a ForeignPtr or use a Storable instance to get a > > MyType directly. OK. I've instances of Storable for all the appropriate types. > > If do recommend reading the FFI spec. It's quite readable and > > explains a lot of the issues. Sure. It helped a lot. Actually, I've been able to do everything I needed so far with just the spec and Foreign.*. > I would also add the chapter 17 of Real World Haskell. you can > read it here: Nice. It shows unsafePerformIO. Some functions returning structs are side effect free. I'm writing bindings I want to put on hackage, so what do you think would fit better the taste of Haskell programmers: pure functions using unsafePerformIO or IO functions? Thanks, Maur?cio From dons at galois.com Wed Dec 10 11:59:15 2008 From: dons at galois.com (Don Stewart) Date: Wed Dec 10 11:52:07 2008 Subject: [Haskell-cafe] Haskell project proposals reddit In-Reply-To: <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> References: <20081210043420.GT5981@scytale.galois.com> <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> Message-ID: <20081210165915.GC11785@scytale.galois.com> josef.svenningsson: > On Wed, Dec 10, 2008 at 5:34 AM, Don Stewart wrote: > > I'd like to echo Jason's remarks earlier. > > > > http://www.reddit.com/r/haskell_proposals/ > > > > We've tried for a couple of years now to efficiently track 'wanted > > libraries' for the community, but never with much success. > > > > In particular, two approaches have been tried: > > > > * a wiki page > > * the 200{6,7,8} summer of code trac > > > > neither proved workable long term, likely because no one knew about > > them, they're harder to contribute to and other factors. > > > I think this is a wonderful initiative, but I can't shake the feeling > that reddit is the wrong forum for this. Since reddit is primarily a > news site it penalises old submissions and eventually moves them out > of the front page. I can't see how that behavior is good for our > purposes here. A project proposal that has a thousand upvotes > shouldn't be moved from the list just because the proposal itself is > old. > > If we want something that works in the long run we want something like > reddit but without the "aging" of old submissions. I don't know of any > such thing but there's bound to be one, this being the internet after > all. As Thomas said, the 'top' page is what we're looking for. I'm not really interested in the actual number of votes, more in how cheap it is to add ideas, and the discussion that ensues. -- Don From duncan.coutts at worc.ox.ac.uk Wed Dec 10 12:18:53 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 10 12:12:01 2008 Subject: [Haskell-cafe] Re: Can my type be allowed as return type in FFI? In-Reply-To: References: <1228912256.10115.482.camel@localhost> <20081210124419.GL22600@Andrea.Nowhere.net> Message-ID: <1228929533.10115.512.camel@localhost> On Wed, 2008-12-10 at 14:17 -0200, Mauricio wrote: > > > > foreign import "nameOfFunction" nameOfFunction > > > > :: IO MyType > > > > > > > Is it possible to write a new MyType and make it allowed as > > > > a return type from foreign functions? Is changing the > > > > compiler the only way to do that? > > > > Of course you're not really returning a MyType but a pointer > > > to one. (...) > > This would solve half my problem. Can I always trust that? I've > been told before that everytime a C function returns a struct it > is actually returning a pointer, but I wasn't able to find that > written in stone so that I can trust it to be valid anywhere > Haskell will run and for any return type (like a struct containing > just a char, for instance). Sorry, I'm not talking about how C implements passing structures to functions. The Haskell FFI can only bind functions that pass structures by pointer, not by value. So if you've got a C function that passes them by value then you need to write a wrapper function in C and bind to that. That way you end up with a pointer on the Haskell side. > How does that pointer work? My code didn't provide it to the C > function, so, I believe I don't have to deallocate it. Where does > the memory it points to live? Did Haskell FFI engine gave that > pointer to the C function? How much time is it going to live? > Enough so I can 'peek' it? You explicitly pass the pointer and typically you manage the allocation and de-allocation in Haskell using functions from the Foreign.* modules. There is no magic. You have to manage all the allocation, writing and object lifetimes explicitly. The Foreign.* modules provide many convenience functions that make this simpler in many cases. > Nice. It shows unsafePerformIO. Some functions returning structs > are side effect free. I'm writing bindings I want to put on > hackage, so what do you think would fit better the taste of > Haskell programmers: pure functions using unsafePerformIO or > IO functions? If the C function is genuinely pure apart from having to allocate and de-allocate temporary objects (and you treat all such objects by value using Storable) then it's ok to make it pure in Haskell using unsafePerformIO. If it mutates any input parameters or uses objects managed by reference using ForeignPtr then it's not ok. So it really depends on what the C code is doing. Duncan From duncan.coutts at worc.ox.ac.uk Wed Dec 10 12:21:19 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Dec 10 12:15:05 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> Message-ID: <1228929679.10115.516.camel@localhost> On Wed, 2008-12-10 at 15:30 +0100, Sean Leather wrote: > [Responding to an old (but still relevant) thread...] > > I'm getting this error as well, both in 2.3.0 and 2.4.1. > > Suppose that I wanted to generate documentation for everything in my > Cabal package except for the modules with Template Haskell in them. Is > it enough to add {-# OPTIONS_HADDOCK hide #-} to each of these > modules? I tried, but it didn't pan out like I hoped. I'm still > getting the same error. Is there something else I can do? As I understand it, using hide like that just means there will be no documentation page for that module. However it still has to parse that module since things in it may be re-exported from other modules and have documentation inserted into the docs for those modules. For example the documentation for the Prelude works this way, it's mostly re-exported from internal hidden GHC.* modules. (It may occasionally be broken but that's the way it's supposed to work). Duncan From jwlato at gmail.com Wed Dec 10 12:22:41 2008 From: jwlato at gmail.com (John Lato) Date: Wed Dec 10 12:15:40 2008 Subject: [Haskell-cafe] Re: Iteratee-based IO and lightweight monadic Message-ID: <9979e72e0812100922y7edba5b0sa7c6b9d9824d39f0@mail.gmail.com> > From: "Artyom Shalkhakov" > > Hello, > > Is anybody planning to use these shiny new ways for doing IO? > > I'm also interested in a fair comparison of ByteString/Binary > with iteratee-based IO. Has anybody done this? > I would like to use Iteratee-based IO, and have been doing some experiments with it recently for my problem domain (reading sound files). There has been a discussion recently on the haskell-art list about this specific topic. I posted some timing/memory data, and links to my test code, which you should be able to find in the archives if you're interested. I have found that, with my specific implementations and test case, Iteratee-based IO is slightly slower than the most performant ByteString/Binary code I used, however it uses significantly less memory and has nice composability. Also note that my ByteString-based reader actually reads strict ByteStrings and outputs a stream of UArr Doubles (from the uvector package) using unsafeInterleaveIO rather than using lazy ByteStrings directly. Other implementations made different choices, which I covered in some detail in the mentioned thread. Oleg has recently (after I did my tests) published a small library for reading TIFF files using Iteratees. This new code offers some significant advantages over what I was doing with Iteratees, and may offer performance benefits. More work for me... Unfortunately, neither approach (Iteratee nor ByteString) is yet competitive with hsndfile/libsndfile. However, an Iteratee layer that uses hsndfile to read could be implemented, giving the benefits of the Iteratee approach with high performance. I believe the hsndfile authors are interested in this. It should be very easy to implement. From haskell at list.mightyreason.com Wed Dec 10 12:34:16 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Dec 10 12:27:30 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: References: Message-ID: <493FFD98.2060209@list.mightyreason.com> Is there anyway to track down and fix why haskell-src-exts-0.4.4.1 still gets "haddock: parse error in doc string" when I try to get cabal to haddock the package? From ross at soi.city.ac.uk Wed Dec 10 12:42:30 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Wed Dec 10 12:35:30 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: <493FFD98.2060209@list.mightyreason.com> References: <493FFD98.2060209@list.mightyreason.com> Message-ID: <20081210174230.GA5726@soi.city.ac.uk> On Wed, Dec 10, 2008 at 05:34:16PM +0000, ChrisK wrote: > Is there anyway to track down and fix why haskell-src-exts-0.4.4.1 still gets > > "haddock: parse error in doc string" > > when I try to get cabal to haddock the package? Line numbers would be handy. In this case, the problem is the "Original:" line in some of the module headers. From haskell at list.mightyreason.com Wed Dec 10 12:48:38 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Dec 10 12:41:41 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: <20081210174230.GA5726@soi.city.ac.uk> References: <493FFD98.2060209@list.mightyreason.com> <20081210174230.GA5726@soi.city.ac.uk> Message-ID: <494000F6.5050205@list.mightyreason.com> Ross Paterson wrote: > On Wed, Dec 10, 2008 at 05:34:16PM +0000, ChrisK wrote: >> Is there anyway to track down and fix why haskell-src-exts-0.4.4.1 still gets >> >> "haddock: parse error in doc string" >> >> when I try to get cabal to haddock the package? > > Line numbers would be handy. > > In this case, the problem is the "Original:" line in some of the module > headers. Indeed, I just found that. I wonder where in the universe this is documented. Oh well. I also had to change -- $x and -- $( comments. A "darcs diff -u" patch is attached. Cheers, Chris -------------- next part -------------- diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Build.hs new-haskell-src-exts/Language/Haskell/Exts/Build.hs --- old-haskell-src-exts/Language/Haskell/Exts/Build.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Build.hs 2008-12-10 17:46:47.000000000 +0000 @@ -1,7 +1,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Build --- Original : Language.Haskell.Syntax -- Copyright : (c) The GHC Team, 1997-2000, -- (c) Niklas Broberg 2004 -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Lexer.hs new-haskell-src-exts/Language/Haskell/Exts/Lexer.hs --- old-haskell-src-exts/Language/Haskell/Exts/Lexer.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Lexer.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Lexer --- Original : Language.Haskell.Lexer -- Copyright : (c) The GHC Team, 1997-2000 -- (c) Niklas Broberg, 2004 -- License : BSD-style (see the file LICENSE.txt) @@ -83,8 +82,8 @@ | THDecQuote -- [d| | THTypQuote -- [t| | THCloseQuote -- |] - | THIdEscape (String) -- $x - | THParenEscape -- $( + | THIdEscape (String) -- dollar x + | THParenEscape -- dollar ( | THVarQuote -- 'x (but without the x) | THTyQuote -- ''T (but without the T) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs new-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs --- old-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.ParseMonad --- Original : Language.Haskell.ParseMonad -- Copyright : (c) The GHC Team, 1997-2000 -- License : BSD-style (see the file libraries/base/LICENSE) -- diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs new-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs --- old-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.ParseUtils --- Original : Language.Haskell.ParseUtils -- Copyright : (c) Niklas Broberg 2004, -- (c) The GHC Team, 1997-2000 -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Parser.ly new-haskell-src-exts/Language/Haskell/Exts/Parser.ly --- old-haskell-src-exts/Language/Haskell/Exts/Parser.ly 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Parser.ly 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ > ----------------------------------------------------------------------------- > -- | > -- Module : Language.Haskell.Exts.Parser -> -- Original : Language.Haskell.Parser > -- Copyright : (c) Niklas Broberg 2004, > -- Original (c) Simon Marlow, Sven Panne 1997-2000 > -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Pretty.hs new-haskell-src-exts/Language/Haskell/Exts/Pretty.hs --- old-haskell-src-exts/Language/Haskell/Exts/Pretty.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Pretty.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Pretty --- Original : Language.Haskell.Pretty -- Copyright : (c) Niklas Broberg 2004, -- (c) The GHC Team, Noel Winstanley 1997-2000 -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Syntax.hs new-haskell-src-exts/Language/Haskell/Exts/Syntax.hs --- old-haskell-src-exts/Language/Haskell/Exts/Syntax.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Syntax.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Syntax --- Original : Language.Haskell.Syntax -- Copyright : (c) Niklas Broberg 2004, -- (c) The GHC Team, 1997-2000 -- License : BSD-style (see the file LICENSE.txt) From haskell at list.mightyreason.com Wed Dec 10 12:48:38 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Wed Dec 10 12:41:52 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: <20081210174230.GA5726@soi.city.ac.uk> References: <493FFD98.2060209@list.mightyreason.com> <20081210174230.GA5726@soi.city.ac.uk> Message-ID: <494000F6.5050205@list.mightyreason.com> Ross Paterson wrote: > On Wed, Dec 10, 2008 at 05:34:16PM +0000, ChrisK wrote: >> Is there anyway to track down and fix why haskell-src-exts-0.4.4.1 still gets >> >> "haddock: parse error in doc string" >> >> when I try to get cabal to haddock the package? > > Line numbers would be handy. > > In this case, the problem is the "Original:" line in some of the module > headers. Indeed, I just found that. I wonder where in the universe this is documented. Oh well. I also had to change -- $x and -- $( comments. A "darcs diff -u" patch is attached. Cheers, Chris -------------- next part -------------- diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Build.hs new-haskell-src-exts/Language/Haskell/Exts/Build.hs --- old-haskell-src-exts/Language/Haskell/Exts/Build.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Build.hs 2008-12-10 17:46:47.000000000 +0000 @@ -1,7 +1,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Build --- Original : Language.Haskell.Syntax -- Copyright : (c) The GHC Team, 1997-2000, -- (c) Niklas Broberg 2004 -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Lexer.hs new-haskell-src-exts/Language/Haskell/Exts/Lexer.hs --- old-haskell-src-exts/Language/Haskell/Exts/Lexer.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Lexer.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Lexer --- Original : Language.Haskell.Lexer -- Copyright : (c) The GHC Team, 1997-2000 -- (c) Niklas Broberg, 2004 -- License : BSD-style (see the file LICENSE.txt) @@ -83,8 +82,8 @@ | THDecQuote -- [d| | THTypQuote -- [t| | THCloseQuote -- |] - | THIdEscape (String) -- $x - | THParenEscape -- $( + | THIdEscape (String) -- dollar x + | THParenEscape -- dollar ( | THVarQuote -- 'x (but without the x) | THTyQuote -- ''T (but without the T) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs new-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs --- old-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/ParseMonad.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.ParseMonad --- Original : Language.Haskell.ParseMonad -- Copyright : (c) The GHC Team, 1997-2000 -- License : BSD-style (see the file libraries/base/LICENSE) -- diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs new-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs --- old-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/ParseUtils.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.ParseUtils --- Original : Language.Haskell.ParseUtils -- Copyright : (c) Niklas Broberg 2004, -- (c) The GHC Team, 1997-2000 -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Parser.ly new-haskell-src-exts/Language/Haskell/Exts/Parser.ly --- old-haskell-src-exts/Language/Haskell/Exts/Parser.ly 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Parser.ly 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ > ----------------------------------------------------------------------------- > -- | > -- Module : Language.Haskell.Exts.Parser -> -- Original : Language.Haskell.Parser > -- Copyright : (c) Niklas Broberg 2004, > -- Original (c) Simon Marlow, Sven Panne 1997-2000 > -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Pretty.hs new-haskell-src-exts/Language/Haskell/Exts/Pretty.hs --- old-haskell-src-exts/Language/Haskell/Exts/Pretty.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Pretty.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Pretty --- Original : Language.Haskell.Pretty -- Copyright : (c) Niklas Broberg 2004, -- (c) The GHC Team, Noel Winstanley 1997-2000 -- License : BSD-style (see the file LICENSE.txt) diff -rN -u old-haskell-src-exts/Language/Haskell/Exts/Syntax.hs new-haskell-src-exts/Language/Haskell/Exts/Syntax.hs --- old-haskell-src-exts/Language/Haskell/Exts/Syntax.hs 2008-12-10 17:46:47.000000000 +0000 +++ new-haskell-src-exts/Language/Haskell/Exts/Syntax.hs 2008-12-10 17:46:47.000000000 +0000 @@ -2,7 +2,6 @@ ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Exts.Syntax --- Original : Language.Haskell.Syntax -- Copyright : (c) Niklas Broberg 2004, -- (c) The GHC Team, 1997-2000 -- License : BSD-style (see the file LICENSE.txt) From niklas.broberg at gmail.com Wed Dec 10 13:59:10 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Wed Dec 10 13:52:09 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4 In-Reply-To: <494000F6.5050205@list.mightyreason.com> References: <493FFD98.2060209@list.mightyreason.com> <20081210174230.GA5726@soi.city.ac.uk> <494000F6.5050205@list.mightyreason.com> Message-ID: > Indeed, I just found that. I wonder where in the universe this is > documented. Oh well. I also had to change -- $x and -- $( comments. A > "darcs diff -u" patch is attached. Thanks a lot Chris, patch applied to the repo and will appear in the next release. Cheers, /Niklas From haakon.eriksen at far.no Wed Dec 10 14:05:00 2008 From: haakon.eriksen at far.no (Haakon Meland Eriksen) Date: Wed Dec 10 13:57:43 2008 Subject: [Haskell-cafe] Fram Message-ID: <494012DC.7000600@far.no> Dear Haskell community, It was kindly suggested to me by John Peterson that I might reach you here and tell you a little bit about Fram, a small Mediawiki extension. Fram lets you intersperse your explanation with actual code, and then Fram extracts and concatenates the code, giving you a file with code for download. This means anyone with access to Fram can improve your code, either by explaining it or by enhancing the code itself. It is released under the GNU GPL version 3 at no cost. Fram is now at version 0.2, and equals the Mediawiki extension RawFile 0.2, written by Belgian developer Philippe Teuwen. Phil and I are collaborating to improve Fram into a fully fledged literate programming tool like "noweb" written by Norman Ramsey. It was originally Ramsey who suggested to me that Fram may be interesting to the Haskell community wiki, so here we are. If this sounds useful, please have a look at http://far.no/fram/ or go below the main-deck into the cabins to explore the articles http://far.no/fram/index.php?title=Fram http://far.no/fram/index.php?title=Test http://far.no/fram/index.php?title=Usbpix and if these don't make sense, have a look at our help page http://far.no/fram/index.php?title=Help:Contents If you are curious about the name, "Fram" is also the name of a famous ship used by Norwegian polar explorers in the last century. It means "Forward". Yours sincerely, Haakon Meland Eriksen From andrewcoppin at btinternet.com Wed Dec 10 16:53:26 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 10 16:46:26 2008 Subject: [Haskell-cafe] Source code Message-ID: <49403A56.9040308@btinternet.com> The library documentation pages on Haskell.org used to have helpful links to the library source code. But they don't seem to be there any more. Anybody know why? From gwern0 at gmail.com Wed Dec 10 17:15:22 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Dec 10 17:08:23 2008 Subject: [Haskell-cafe] Fram In-Reply-To: <494012DC.7000600@far.no> References: <494012DC.7000600@far.no> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Wed, Dec 10, 2008 at 2:05 PM, Haakon Meland Eriksen wrote: > Dear Haskell community, > > It was kindly suggested to me by John Peterson that I might reach you here and tell you a little bit about Fram, a small Mediawiki extension. > > Fram lets you intersperse your explanation with actual code, and then Fram extracts and concatenates the code, giving you a file with code for download. > This means anyone with access to Fram can improve your code, either by explaining it or by enhancing the code itself. It is released under the GNU GPL version 3 at no cost. > > Fram is now at version 0.2, and equals the Mediawiki extension RawFile 0.2, written by Belgian developer Philippe Teuwen. Phil and I are collaborating to improve Fram into a fully fledged literate programming tool like "noweb" written by Norman Ramsey. It was originally Ramsey who suggested to me that Fram may be interesting to the Haskell community wiki, so here we are. What advantages does Fram have over noweb? I've noodled around a little on the Literate Programs wiki ( http://en.literateprograms.org/ ) which uses noweb for providing the source files, and it seemed to work as it should. > Yours sincerely, > Haakon Meland Eriksen - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklAP0QACgkQvpDo5Pfl1oL8yQCdHfy0beCpMZ/+cnscxjKeiXnY LysAn216FhM2qZkN1Rh38hVjcO9EYTPT =mzaa -----END PGP SIGNATURE----- From jason.dusek at gmail.com Wed Dec 10 19:00:17 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Dec 10 18:53:15 2008 Subject: [Haskell-cafe] Haskell project proposals reddit In-Reply-To: <4c44d90b0812100658hea3f4b3ob7368db9324cb6f7@mail.gmail.com> References: <20081210043420.GT5981@scytale.galois.com> <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> <4c44d90b0812100658hea3f4b3ob7368db9324cb6f7@mail.gmail.com> Message-ID: <42784f260812101600h196f5083g3fa8e8eff36eda19@mail.gmail.com> I think you are overlooking the Web 2.0 aspect of this. -- _jsn From dons at galois.com Wed Dec 10 20:13:17 2008 From: dons at galois.com (Don Stewart) Date: Wed Dec 10 20:06:10 2008 Subject: [Haskell-cafe] Projects that depend on the vty package? In-Reply-To: References: Message-ID: <20081211011317.GD13313@scytale.galois.com> coreyoconnor: > Hello, > For further development of the vty package I'm really only paying > attention to the requirements that fall out of the Yi project. Are > there any other projects that depend on the vty package? > > In addition, the vty project has it's own wiki: http://trac.haskell.org/vty/ > Right now there isn't much information there but it is a great place > to send bug reports or enhancement requests if you have them. You can grep the complete .cabal file set on hackage, which I did, yielding the following versions of the follwoing packages: ./yi-vty/0.3/yi-vty.cabal ./yi-vty/0.2/yi-vty.cabal ./yi-vty/0.2.1/yi-vty.cabal ./yi/0.4.1/yi.cabal ./yi/0.4.6/yi.cabal ./yi/0.3/yi.cabal ./yi/0.5.0.1/yi.cabal ./yi/0.2/yi.cabal ./yi/0.4.3/yi.cabal ./yi/0.4.6.2/yi.cabal ./yi/0.5.2/yi.cabal ./yi/0.4/yi.cabal ./LambdaHack/0.1.20080413/LambdaHack.cabal ./LambdaHack/0.1.20080412/LambdaHack.cabal -- Don From ok at cs.otago.ac.nz Wed Dec 10 23:58:23 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Dec 10 23:51:24 2008 Subject: [Haskell-cafe] Re: Can my type be allowed as return type in FFI? In-Reply-To: References: <1228912256.10115.482.camel@localhost> <20081210124419.GL22600@Andrea.Nowhere.net> Message-ID: On 11 Dec 2008, at 5:17 am, Mauricio wrote: > This would solve half my problem. Can I always trust that? I've > been told before that everytime a C function returns a struct it > is actually returning a pointer, but I wasn't able to find that > written in stone That's because it isn't true. In fact one of the classical ways for a C function to return a struct is to be *GIVEN* a pointer, e.g., struct Foo f(......) { ... return x; } => void f(struct Foo *_hidden, ......) { ... *_hidden = x; return; } and obviously a C compiler is entitled to return a small struct in registers if it feels like it. From dons at galois.com Thu Dec 11 00:35:24 2008 From: dons at galois.com (Don Stewart) Date: Thu Dec 11 00:28:15 2008 Subject: [Haskell-cafe] Retrospective on 2008? Message-ID: <20081211053524.GB13564@scytale.galois.com> I've been kicking the idea around of a 2008 retrospective. How did we do this year? After all, it has been a dramatic growth period (we're close to 600 people a day in #haskell now, for example, and many new faces!) Some ideas: * 10 best new libraries * 10 best new apps * 10 most influential blog posts * best new library by category Determing this is an interesting task. To start with, I scanned hackage. Some stats: * Hackage currently holds 914 applications and libraries. * 601 of them were released on Hackage this year: http://galois.com/~dons/tmp/new-releases-2008.txt Which is rather impressive, I have to say. We're getting better at the production of new libraries and apps (I imagine all the releases are feeding into new apps and libs in new areas not easily reachable before). The last couple of months, we're averaging around 10 uploads a day, in fact. You can see the upload growth here, http://galois.com/~dons/images/hackage-daily-graph.png We've fundamentally transformed the suitability of Haskell and GHC in a range of domains through the production of these apps and libraries. Well done everyone! Now, as for determining which new things make the top 10, a chance to apply some heuristics? (Most voted on? Most downloaded? Most depended upon by other things?). Any thoughts? Anyone have their own top 10 list? Or other key events of the year? -- Don From cetin.sert at gmail.com Thu Dec 11 01:49:33 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Thu Dec 11 01:42:31 2008 Subject: [Haskell-cafe] type error Message-ID: <1ff5dedc0812102249m14e0efcci9458dd5b09364853@mail.gmail.com> Hi, Why does this not function? Prelude> sequence [print 'a', print 2] 'a' 2 [(),()] *Prelude> let myprint = print* *Prelude> sequence [myprint 'a', myprint 2]* :1:18: Couldn't match expected type `()' against inferred type `Char' In the first argument of `myprint', namely 'a' In the expression: myprint 'a' In the first argument of `sequence', namely `[myprint 'a', myprint 2]' Can providing some type annotations (interactively in ghci or in some .hs file) help solve the problem? Best Regards, CS -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/d2d31379/attachment.htm From voigt at tcs.inf.tu-dresden.de Thu Dec 11 01:55:00 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Thu Dec 11 01:47:58 2008 Subject: [Haskell-cafe] type error In-Reply-To: <1ff5dedc0812102249m14e0efcci9458dd5b09364853@mail.gmail.com> References: <1ff5dedc0812102249m14e0efcci9458dd5b09364853@mail.gmail.com> Message-ID: <4940B944.1060907@tcs.inf.tu-dresden.de> Cetin Sert wrote: > Hi, > > Why does this not function? > > Prelude> sequence [print 'a', print 2] > 'a' > 2 > [(),()] > *Prelude> let myprint = print* > *Prelude> sequence [myprint 'a', myprint 2]* > > :1:18: > Couldn't match expected type `()' against inferred type `Char' > In the first argument of `myprint', namely 'a' > In the expression: myprint 'a' > In the first argument of `sequence', namely > `[myprint 'a', myprint 2]' The problem is the monomorphism restriction: ~> ghci GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :t print print :: (Show a) => a -> IO () Prelude> let myprint=print Prelude> :t myprint myprint :: () -> IO () Prelude> :q Leaving GHCi. ~> ghci -fno-monomorphism-restriction GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> let myprint=print Prelude> :t myprint myprint :: (Show a) => a -> IO () > Can providing some type annotations (interactively in ghci or in some > .hs file) help solve the problem? Yes. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From jason.dusek at gmail.com Thu Dec 11 03:18:17 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Dec 11 03:11:14 2008 Subject: [Haskell-cafe] type error In-Reply-To: <1ff5dedc0812102249m14e0efcci9458dd5b09364853@mail.gmail.com> References: <1ff5dedc0812102249m14e0efcci9458dd5b09364853@mail.gmail.com> Message-ID: <42784f260812110018s34b6b251u39fa79aad04f8b7e@mail.gmail.com> You can disable the monomorphism restriction in your .ghci so it needn't trouble your interactive sessions further. My .ghci follows my signature. -- _jsn :set -XOverlappingInstances :set -XNoMonomorphismRestriction :set -XUnicodeSyntax :set -XArrows :set -Wall :set -fno-warn-name-shadowing :set -fwarn-unused-imports :set -fglasgow-exts :set +t From artyom.shalkhakov at gmail.com Thu Dec 11 03:30:59 2008 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Thu Dec 11 03:23:55 2008 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 64, Issue 17 In-Reply-To: <9157df230812100933hdc55cf8i49782da33f2356b@mail.gmail.com> References: <20081210161047.6B0A93246DF@www.haskell.org> <9157df230812100933hdc55cf8i49782da33f2356b@mail.gmail.com> Message-ID: <2076f2f90812110030p2ab817f6p3f78ee2115ef9974@mail.gmail.com> Hello, 2008/12/10 Ben : > do you have any plans for iteratee based IO? I would like to use it in XHB (X Haskell Bindings). We use ByteStrings ATM, but I find the code hard to read. > have you seen takusen? Actually, I only took a glance or two. Regards, Artyom Shalkhakov. From ketil at malde.org Thu Dec 11 04:46:10 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Dec 11 04:39:08 2008 Subject: [Haskell-cafe] Haskell project proposals reddit In-Reply-To: <42784f260812101600h196f5083g3fa8e8eff36eda19@mail.gmail.com> (Jason Dusek's message of "Wed\, 10 Dec 2008 16\:00\:17 -0800") References: <20081210043420.GT5981@scytale.galois.com> <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> <4c44d90b0812100658hea3f4b3ob7368db9324cb6f7@mail.gmail.com> <42784f260812101600h196f5083g3fa8e8eff36eda19@mail.gmail.com> Message-ID: <873agvf3j1.fsf@malde.org> "Jason Dusek" writes: > I think you are overlooking the Web 2.0 aspect of this. I've been wondering what reddit brings to the table that makes it worth keeping track of yet another web site, registering yet another user account, learning yet another interface. Assuming you're not just being sarcastic about buzzword compliance, would you - or somebody else - care to elaborate a little bit what the advantage is here? -k -- If I haven't seen further, it is by standing in the footprints of giants From leather at cs.uu.nl Thu Dec 11 05:29:05 2008 From: leather at cs.uu.nl (Sean Leather) Date: Thu Dec 11 05:22:02 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1228929679.10115.516.camel@localhost> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> Message-ID: <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> > > Suppose that I wanted to generate documentation for everything in my > > Cabal package except for the modules with Template Haskell in them. Is > > it enough to add {-# OPTIONS_HADDOCK hide #-} to each of these > > modules? I tried, but it didn't pan out like I hoped. I'm still > > getting the same error. Is there something else I can do? > > As I understand it, using hide like that just means there will be no > documentation page for that module. However it still has to parse that > module since things in it may be re-exported from other modules and have > documentation inserted into the docs for those modules. > Thanks, Duncan. That makes sense. Now, I'm trying to use #ifndef __HADDOCK__ / #endif around those same modules, and I'm still running into the same internal Haddock error: > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing I've been using "cabal haddock" to run haddock on my package. I also get the same error using haddock directly: > $ haddock -odir=tmp --debug --verbose --html Generics/EMGM.hs > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing Any other suggestions? Thanks, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/b2e7a9d2/attachment.htm From magnus at therning.org Thu Dec 11 05:52:56 2008 From: magnus at therning.org (Magnus Therning) Date: Thu Dec 11 05:46:10 2008 Subject: [Haskell-cafe] Projects that depend on the vty package? In-Reply-To: References: Message-ID: On Wed, Dec 3, 2008 at 7:57 PM, Corey O'Connor wrote: > Hello, > For further development of the vty package I'm really only paying > attention to the requirements that fall out of the Yi project. Are > there any other projects that depend on the vty package? > > In addition, the vty project has it's own wiki: http://trac.haskell.org/vty/ > Right now there isn't much information there but it is a great place > to send bug reports or enhancement requests if you have them. I haven't been using it for anything real, but I was playing around with it in preparation for yet another project that hasn't taken off (and it never might). Anyway, it is a nice _low-level_ library, do you have any plans on building convenient things on top of it? Basic widgets such as dialogues and lists spring to mind... This is a rather pathetic list widget I came up with at the time: module Main where import Data.Maybe import Graphics.Vty import qualified Data.ByteString.Char8 as B options = [ "01 Foo", "02 Bar", "03 Baz", "04 Qux", "05 Quux", "06 Quuux", "07 Foo", "08 Bar", "09 Baz", "10 Qux", "11 Quux", "12 Quuux", "13 Foo", "14 Bar", "15 Baz", "16 Qux", "17 Quux", "18 Quuux", "19 Foo", "20 Bar", "21 Baz", "22 Qux", "23 Quux", "24 Quuux", "25 Foo", "26 Bar", "27 Baz", "28 Qux", "29 Quux", "30 Quuux", "31 Foo", "32 Bar", "33 Baz", "34 Qux", "35 Quux", "36 Quuux", "37 Foo", "38 Bar", "39 Baz", "40 Qux", "41 Quux", "42 Quuux", "43 Foo", "44 Bar", "45 Baz", "46 Qux", "47 Quux", "48 Quuux", "49 Foo", "50 Bar", "51 Baz", "52 Qux", "53 Quux", "54 Quuux", "55 Foo", "56 Bar", "57 Baz", "58 Qux", "59 Quux", "60 Quuux" ] main :: IO () main = do vt <- mkVty getChoice vt options >>= putStrLn . show {- - List choice widget for Vty. -} getChoice :: Vty -> [String] -> IO (Maybe (Int, String)) getChoice vt opts = do (sx, sy) <- getSize vt _getChoice vt opts 0 sx sy _getChoice vt opts idx sx sy = let _calcTop winHeight listLength idx = max 0 ((min listLength ((max 0 (idx - winHeight `div` 2)) + winHeight)) - winHeight) _top = _calcTop sy (length opts) idx _visible_opts = take sy (drop _top opts) in do update vt (render _visible_opts (idx - _top) sx) k <- getEvent vt case k of EvKey KDown [] -> _getChoice vt opts (min (length opts - 1) (idx + 1)) sx sy EvKey KUp [] -> _getChoice vt opts (max 0 (idx - 1)) sx sy EvKey KEsc [] -> shutdown vt >> return Nothing EvKey KEnter [] -> shutdown vt >> return (Just $ (idx, opts !! idx)) EvResize nx ny -> _getChoice vt opts idx nx ny _ -> _getChoice vt opts idx sx sy render opts idx sx = pic { pImage = foldr1 (<->) $ map _render1 $ zip [0..] opts } where _render1 (i, o) = renderHFill attr ' ' 5 <|> renderBS (_attr i) (B.pack o) <|> renderHFill attr ' ' (sx - 5 - length o) _attr i = if i /= idx then attr else setRV attr /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From duncan.coutts at worc.ox.ac.uk Thu Dec 11 06:22:28 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 06:15:30 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> Message-ID: <1228994548.10115.544.camel@localhost> On Thu, 2008-12-11 at 11:29 +0100, Sean Leather wrote: > Now, I'm trying to use #ifndef __HADDOCK__ / #endif around those same > modules, and I'm still running into the same internal Haddock error: > > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing > > I've been using "cabal haddock" to run haddock on my package. I also > get the same error using haddock directly: > > > $ haddock -odir=tmp --debug --verbose --html > Generics/EMGM.hs > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing > > Any other suggestions? Sorry, you'll have to ask David. Have you filed a ticket for this in the haddock trac so that he doesn't forget? http://trac.haskell.org/haddock/ Duncan From hjgtuyl at chello.nl Thu Dec 11 08:00:17 2008 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Thu Dec 11 07:53:26 2008 Subject: [Haskell-cafe] Retrospective on 2008? In-Reply-To: <20081211053524.GB13564@scytale.galois.com> References: <20081211053524.GB13564@scytale.galois.com> Message-ID: On Thu, 11 Dec 2008 06:35:24 +0100, Don Stewart wrote: > > * Hackage currently holds 914 applications and libraries. Using the commands: cabal update cabal list | fgrep " * " | wc I counted 927 entries. -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From dougal at dougalstanton.net Thu Dec 11 08:13:00 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Thu Dec 11 08:06:00 2008 Subject: [Haskell-cafe] Retrospective on 2008? In-Reply-To: References: <20081211053524.GB13564@scytale.galois.com> Message-ID: <2d3641330812110513j3455396bh30edd3d60011e266@mail.gmail.com> On Thu, Dec 11, 2008 at 1:00 PM, Henk-Jan van Tuyl wrote: > > Using the commands: > cabal update > cabal list | fgrep " * " | wc > I counted 927 entries. > Unfortunately that's not a reliable means of determining cabal packages. (Baffling, I know.) I think it actually lists things you have installed from other sources, too. For instance: $ cabal list | grep cairo * cairo Homepage: http://haskell.org/gtk2hs/archives/2006/01/26/cairo-eye-candy/ $ cabal install cairo cabal: There is no package named cairo Last time this came up there was mention of adding an option to only list things which cabal has control over. I don't know if anything has come of that idea. Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From duncan.coutts at worc.ox.ac.uk Thu Dec 11 08:22:01 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 08:15:01 2008 Subject: [Haskell-cafe] Retrospective on 2008? In-Reply-To: References: <20081211053524.GB13564@scytale.galois.com> Message-ID: <1229001721.10115.558.camel@localhost> On Thu, 2008-12-11 at 14:00 +0100, Henk-Jan van Tuyl wrote: > On Thu, 11 Dec 2008 06:35:24 +0100, Don Stewart wrote: > > > > > * Hackage currently holds 914 applications and libraries. > > Using the commands: > cabal update > cabal list | fgrep " * " | wc > I counted 927 entries. The most reliable method is to use cabal list --simple-output eg all package versions: $ cabal list --simple-output | wc -l 2794 distinct package names $ cabal list --simple-output | cut -d' ' -f 1 | uniq | wc -l 932 top 10 most uploaded packages $ cabal list --simple-output | cut -d' ' -f 1 | uniq -c | sort -n | tail 14 hake 14 mueval 16 haskell-src-exts 18 category-extras 18 HXQ 19 cabal2arch 20 regexpr 20 sessions 21 reactive 31 panda There's also http://hackage.haskell.org/cgi-bin/hackage-scripts/stats though for some reason it does not agree with us. Duncan From duncan.coutts at worc.ox.ac.uk Thu Dec 11 08:25:49 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 08:18:46 2008 Subject: [Haskell-cafe] Retrospective on 2008? In-Reply-To: <2d3641330812110513j3455396bh30edd3d60011e266@mail.gmail.com> References: <20081211053524.GB13564@scytale.galois.com> <2d3641330812110513j3455396bh30edd3d60011e266@mail.gmail.com> Message-ID: <1229001949.10115.561.camel@localhost> On Thu, 2008-12-11 at 13:13 +0000, Dougal Stanton wrote: > On Thu, Dec 11, 2008 at 1:00 PM, Henk-Jan van Tuyl wrote: > > > > Using the commands: > > cabal update > > cabal list | fgrep " * " | wc > > I counted 927 entries. > > > > Unfortunately that's not a reliable means of determining cabal > packages. (Baffling, I know.) I think it actually lists things you > have installed from other sources, too. For instance: > > > $ cabal list | grep cairo > * cairo > Homepage: http://haskell.org/gtk2hs/archives/2006/01/26/cairo-eye-candy/ > $ cabal install cairo > cabal: There is no package named cairo Good point. I'd forgotten that. That'd explain why the hackage stats do not agree with me. > Last time this came up there was mention of adding an option to only > list things which cabal has control over. I don't know if anything has > come of that idea. I expect it'd be easy for some new cabal hacker. I await the patch :-) Duncan From hjgtuyl at chello.nl Thu Dec 11 09:26:38 2008 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Thu Dec 11 09:19:35 2008 Subject: [Haskell-cafe] Retrospective on 2008? In-Reply-To: <2d3641330812110513j3455396bh30edd3d60011e266@mail.gmail.com> References: <20081211053524.GB13564@scytale.galois.com> <2d3641330812110513j3455396bh30edd3d60011e266@mail.gmail.com> Message-ID: On Thu, 11 Dec 2008 14:13:00 +0100, Dougal Stanton wrote: > On Thu, Dec 11, 2008 at 1:00 PM, Henk-Jan van Tuyl > wrote: >> >> Using the commands: >> cabal update >> cabal list | fgrep " * " | wc >> I counted 927 entries. >> > > Unfortunately that's not a reliable means of determining cabal > packages. (Baffling, I know.) I think it actually lists things you > have installed from other sources, too. For instance: > > > $ cabal list | grep cairo > * cairo > Homepage: > http://haskell.org/gtk2hs/archives/2006/01/26/cairo-eye-candy/ > $ cabal install cairo > cabal: There is no package named cairo > I changed the commands to: cabal update cabal list | fgrep " Latest version available: " | wc Now I count 915 entries. -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From pkeir at dcs.gla.ac.uk Thu Dec 11 09:37:41 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Dec 11 09:30:37 2008 Subject: [Haskell-cafe] Multi-parameter Type Class Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> Hi all, I've been trying to refactor my tree conversion code to make better use of type classes; and I've discovered multi-parameter type classes and functional dependencies. I have a class with a function a2b, and I'd like "map" to be used when it's a list of type a. I've created a simple failing example: data Foo = Foo Bar deriving(Show) data Bar = Bar String deriving(Show) class ZOT a b | a -> b where zot :: a -> b instance ZOT Foo Integer where zot x = 17 instance ZOT Bar String where zot x = "Eighteen" instance ZOT [x] [y] where -- This bit zot xs = map zot xs -- fails main = do print $ zot $ Foo $ Bar "Blah" print $ zot $ Bar "Blah" print $ zot $ [Bar "Blah", Bar "Blah"] -- No map here please I know this would work if the third instance of zot explicitly took [Bar] and [String]. Can I not instead generalise for all the ADTs in my tree in the way I've outlined? Must I instantiate for the type of each list pair? Cheers, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/32583b06/attachment.htm From lennart at augustsson.net Thu Dec 11 10:19:23 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Dec 11 10:12:19 2008 Subject: [Haskell-cafe] Multi-parameter Type Class In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> Message-ID: Since your map function is calling zot to convert an x to a y you must state that this is possible: instance ZOT x y => ZOT [x] [y] where zot xs = map zot xs -- Lennart 2008/12/11 Paul Keir : > Hi all, > > I've been trying to refactor my tree conversion code to make > better use of type classes; and I've discovered multi-parameter > type classes and functional dependencies. I have a class with a > function a2b, and I'd like "map" to be used when it's a list of > type a. > > I've created a simple failing example: > > data Foo = Foo Bar deriving(Show) > data Bar = Bar String deriving(Show) > > class ZOT a b | a -> b where > zot :: a -> b > > instance ZOT Foo Integer where > zot x = 17 > > instance ZOT Bar String where > zot x = "Eighteen" > > instance ZOT [x] [y] where -- This bit > zot xs = map zot xs -- fails > > main = do print $ zot $ Foo $ Bar "Blah" > print $ zot $ Bar "Blah" > print $ zot $ [Bar "Blah", Bar "Blah"] -- No map here please > > I know this would work if the third instance of zot > explicitly took [Bar] and [String]. Can I not instead generalise > for all the ADTs in my tree in the way I've outlined? Must I > instantiate for the type of each list pair? > > Cheers, > Paul > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jgoerzen at complete.org Thu Dec 11 10:27:17 2008 From: jgoerzen at complete.org (John Goerzen) Date: Thu Dec 11 10:20:14 2008 Subject: [Haskell-cafe] Re: how to pipe in pure input with HSH? (Would be helpful for sending emails via sendmail/mailx via HSH interface) In-Reply-To: <910ddf450812070454rf74f8c9wf39f512dca166595@mail.gmail.com> References: <910ddf450812070454rf74f8c9wf39f512dca166595@mail.gmail.com> Message-ID: <49413155.5090901@complete.org> Thomas Hartman wrote: > {- > I am trying to figure out a way to send email using HSH and I'm stumped. > > The problem is that there is no ShellCommand instance for a pure > vanilla string, which can be piped into another ShellCommand. There is > a ShellCommand String instance, but the string is a command to be > executed. Hi Thomas, See echo and echoBS here: http://hackage.haskell.org/packages/archive/HSH/1.2.6/doc/html/HSH-ShellEquivs.html#v%3Aecho -- John > > I defined PureInput wrapper around String in an attempt to get this > working, but I'm stumped defining > an fdInvoke method for it. > > class (Show a) => ShellCommand a where > fdInvoke :: > a > -> System.Posix.Types.Fd > -> System.Posix.Types.Fd > -> [System.Posix.Types.Fd] > -> IO () > -> IO [InvokeResult] > > Can someone help out? Below is a stub. > > Thomas. > -} > > import HSH > > newtype PureInput = PureInput { unpureinput :: String } > deriving (Read,Show) > > > -- This works fine, blah blah blah gets outputted > demo1 = runIO $ ( ( ( ("echo blah blah blah") :: String) -|- ( "cat" > :: String) ) :: PipeCommand String String ) > > > -- This is what I want. Specify a pure input string, to be piped into > another command. > -- In this example it's cat, which isn't very usefuol. > -- This would be useful, however, for sending email via sendmail or > mailx, with variable input piped in. > -- The result should be that "blah blah blah" is printed from cat, > just as in demo1. > demo2 = runIO $ (PureInput "blah blah blah") -|- ( "cat" :: String) > > -- How can/should this be done? > instance ShellCommand PureInput where > fdInvoke (PureInput justAString) ifd ofd closefd forkfunc = undefined > From briqueabraque at yahoo.com Thu Dec 11 10:28:04 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Thu Dec 11 10:21:15 2008 Subject: [Haskell-cafe] Re: Can my type be allowed as return type in FFI? In-Reply-To: References: <1228912256.10115.482.camel@localhost> <20081210124419.GL22600@Andrea.Nowhere.net> Message-ID: >> This would solve half my problem. Can I always trust that? I've >> been told before that everytime a C function returns a struct it >> is actually returning a pointer, but I wasn't able to find that >> written in stone > > That's because it isn't true. > In fact one of the classical ways for a C function to > return a struct is to be *GIVEN* a pointer, e.g., > (...) Sure, sorry. I should have said that the C functions fill memory from a given pointer. > and obviously a C compiler is entitled to return a small struct > in registers if it feels like it. If a compiler is compiling code that calls a library, how is it supposed to know if a return pointer is been passed as a register or by using a pointer? The compiler may not have access to the built library to check that. (Begginer question, I never wrote assembly code.) Thanks, Maur?cio From leather at cs.uu.nl Thu Dec 11 10:26:24 2008 From: leather at cs.uu.nl (Sean Leather) Date: Thu Dec 11 10:22:22 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1228994548.10115.544.camel@localhost> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> Message-ID: <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> > > Now, I'm trying to use #ifndef __HADDOCK__ / #endif around those same > > modules, and I'm still running into the same internal Haddock error: > > > > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing > > > > I've been using "cabal haddock" to run haddock on my package. I also > > get the same error using haddock directly: > > > > > $ haddock -odir=tmp --debug --verbose --html > > Generics/EMGM.hs > > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing > The above is true, but then I ran it with --optghc=-D__HADDOCK__ and that fixed the problem. You see, I didn't know who was actually defining the __HADDOCK__ macro. Now, after looking at code for Haddock and Cabal, I realize it's Cabal. Does Cabal 1.6.0.1 actually define this macro? I don't see it listed when I run cabal-install with --verbose=3, but I don't know if it's supposed to be printed. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/cb204a2b/attachment.htm From allbery at ece.cmu.edu Thu Dec 11 10:33:17 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Dec 11 10:26:21 2008 Subject: [Haskell-cafe] Re: Can my type be allowed as return type in FFI? In-Reply-To: References: <1228912256.10115.482.camel@localhost> <20081210124419.GL22600@Andrea.Nowhere.net> Message-ID: <362D58B3-D086-420A-A115-C0A14A1148C3@ece.cmu.edu> On 2008 Dec 11, at 10:28, Mauricio wrote: >>> and obviously a C compiler is entitled to return a small struct >> in registers if it feels like it. > > If a compiler is compiling code that calls a library, how is it > supposed to know if a return pointer is been passed as a register > or by using a pointer? The compiler may not have access to the The rules are specified as part of an ABI. There is a default ABI for a platform, or you can use a special one (document it). IIRC some CPUs allow information about passed/returned values to be passed in a flag word. -- 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 thomas.dubuisson at gmail.com Thu Dec 11 10:30:32 2008 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Dec 11 10:26:31 2008 Subject: [Haskell-cafe] Multi-parameter Type Class In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> Message-ID: <4c44d90b0812110730m6630c54ct2ea39714fdbc8510@mail.gmail.com> I see Lennart answered your question. For more fun you could also do this with TypeFamilies, which are the new hot thing in Haskell type level logic. Since you are just getting into MPTC, FunDeps etc I figured you'd be interested. ------ START CODE ------ {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, TypeSynonymInstances, FlexibleInstances, TypeFamilies #-} data Foo = Foo Bar deriving(Show) data Bar = Bar String deriving(Show) -- A family of types will evaluate from one type to another. -- Here, I chose the word 'Eval', which you could make more meaningful. -- It is basically a function over types. type family Eval b -- This is three definitions for the type function 'Eval' type instance Eval Foo = Integer type instance Eval Bar = String type instance Eval [x] = [Eval x] -- And instead of a functional dependency -- you have a type level function (Eval) that operates on the type 'a'. class ZOT a where zot :: a -> Eval a instance ZOT Foo where zot x = 17 instance ZOT Bar where zot x = "Eighteen" -- And don't forget that x must be an instance of ZOT to apply zot. instance (ZOT x) => ZOT [x] where zot xs = map zot xs main = do print $ zot $ Foo $ Bar "Blah" print $ zot $ Bar "Blah" print $ zot $ [Bar "Blah", Bar "Blah"] -- No map here please ---- 2008/12/11 Paul Keir > Hi all, > > I've been trying to refactor my tree conversion code to make > better use of type classes; and I've discovered multi-parameter > type classes and functional dependencies. I have a class with a > function a2b, and I'd like "map" to be used when it's a list of > type a. > > I've created a simple failing example: > > data Foo = Foo Bar deriving(Show) > data Bar = Bar String deriving(Show) > > class ZOT a b | a -> b where > zot :: a -> b > > instance ZOT Foo Integer where > zot x = 17 > > instance ZOT Bar String where > zot x = "Eighteen" > > instance ZOT [x] [y] where -- This bit > zot xs = map zot xs -- fails > > main = do print $ zot $ Foo $ Bar "Blah" > print $ zot $ Bar "Blah" > print $ zot $ [Bar "Blah", Bar "Blah"] -- No map here please > > I know this would work if the third instance of zot > explicitly took [Bar] and [String]. Can I not instead generalise > for all the ADTs in my tree in the way I've outlined? Must I > instantiate for the type of each list pair? > > Cheers, > 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/20081211/f5588812/attachment.htm From briqueabraque at yahoo.com Thu Dec 11 10:31:53 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Thu Dec 11 10:28:04 2008 Subject: [Haskell-cafe] Re: Can my type be allowed as return type in FFI? In-Reply-To: <1228929533.10115.512.camel@localhost> References: <1228912256.10115.482.camel@localhost> <20081210124419.GL22600@Andrea.Nowhere.net> <1228929533.10115.512.camel@localhost> Message-ID: > Sorry, I'm not talking about how C implements passing structures to > functions. The Haskell FFI can only bind functions that pass structures > by pointer, not by value. So if you've got a C function that passes them > by value then you need to write a wrapper function in C and bind to > that. This should definitely be in the documentation somewhere. I delayed some work for a few weeks with that :) Thanks a lot for making this clear. Maur?cio From pkeir at dcs.gla.ac.uk Thu Dec 11 10:52:44 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Dec 11 10:46:04 2008 Subject: [Haskell-cafe] Multi-parameter Type Class[MESSAGE NOT SCANNED] References: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCB1F@EX2.ad.dcs.gla.ac.uk> I took your suggestion and it worked exactly as I had hoped. Thankyou. GHCI (6.8.2) was though a little concerned, and told me I had an: Illegal instance declaration for `ZOT [x] [y]' and recommended I use -fallow-undecidable-instances. I did, and it worked. What have I done though? The word "undecidable" scares me a little :) ---SNIP--- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/8bc9bc18/attachment.htm From pkeir at dcs.gla.ac.uk Thu Dec 11 10:53:13 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Dec 11 10:49:26 2008 Subject: [Haskell-cafe] Multi-parameter Type Class[MESSAGE NOT SCANNED] References: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> <4c44d90b0812110730m6630c54ct2ea39714fdbc8510@mail.gmail.com> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCB20@EX2.ad.dcs.gla.ac.uk> Thanks to you both, that also looks fantastic. I'll print it out; put it under my pillow; let it brew overnight and then push in tomorrow ;) -----Original Message----- From: Thomas DuBuisson [mailto:thomas.dubuisson@gmail.com] Sent: Thu 11/12/2008 15:30 To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Multi-parameter Type Class[MESSAGE NOT SCANNED] I see Lennart answered your question. For more fun you could also do this with TypeFamilies, which are the new hot thing in Haskell type level logic. Since you are just getting into MPTC, FunDeps etc I figured you'd be interested. ------ START CODE ------ {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, TypeSynonymInstances, FlexibleInstances, TypeFamilies #-} data Foo = Foo Bar deriving(Show) data Bar = Bar String deriving(Show) -- A family of types will evaluate from one type to another. -- Here, I chose the word 'Eval', which you could make more meaningful. -- It is basically a function over types. type family Eval b -- This is three definitions for the type function 'Eval' type instance Eval Foo = Integer type instance Eval Bar = String type instance Eval [x] = [Eval x] -- And instead of a functional dependency -- you have a type level function (Eval) that operates on the type 'a'. class ZOT a where zot :: a -> Eval a instance ZOT Foo where zot x = 17 instance ZOT Bar where zot x = "Eighteen" -- And don't forget that x must be an instance of ZOT to apply zot. instance (ZOT x) => ZOT [x] where zot xs = map zot xs main = do print $ zot $ Foo $ Bar "Blah" print $ zot $ Bar "Blah" print $ zot $ [Bar "Blah", Bar "Blah"] -- No map here please ---- 2008/12/11 Paul Keir > Hi all, > > I've been trying to refactor my tree conversion code to make > better use of type classes; and I've discovered multi-parameter > type classes and functional dependencies. I have a class with a > function a2b, and I'd like "map" to be used when it's a list of > type a. > > I've created a simple failing example: > > data Foo = Foo Bar deriving(Show) > data Bar = Bar String deriving(Show) > > class ZOT a b | a -> b where > zot :: a -> b > > instance ZOT Foo Integer where > zot x = 17 > > instance ZOT Bar String where > zot x = "Eighteen" > > instance ZOT [x] [y] where -- This bit > zot xs = map zot xs -- fails > > main = do print $ zot $ Foo $ Bar "Blah" > print $ zot $ Bar "Blah" > print $ zot $ [Bar "Blah", Bar "Blah"] -- No map here please > > I know this would work if the third instance of zot > explicitly took [Bar] and [String]. Can I not instead generalise > for all the ADTs in my tree in the way I've outlined? Must I > instantiate for the type of each list pair? > > Cheers, > 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/20081211/dfd59013/attachment.htm From daniel.is.fischer at web.de Thu Dec 11 11:32:09 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Dec 11 11:22:39 2008 Subject: [Haskell-cafe] Multi-parameter Type Class[MESSAGE NOT SCANNED] In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C80CCB1F@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> <3CDFB8AFEA98E34CB599475AB11589C80CCB1F@EX2.ad.dcs.gla.ac.uk> Message-ID: <200812111732.09121.daniel.is.fischer@web.de> Am Donnerstag, 11. Dezember 2008 16:52 schrieb Paul Keir: > I took your suggestion and it worked exactly as I had hoped. Thankyou. > > GHCI (6.8.2) was though a little concerned, and told me > I had an: Illegal instance declaration for `ZOT [x] [y]' > and recommended I use -fallow-undecidable-instances. I did, > and it worked. What have I done though? The word "undecidable" > scares me a little :) > > ---SNIP--- It's not dangerous. ghci told you that the Coverage Condition failed for the functional dependency, read section 8.6.3 of the user's guide for more info, so instance inference is not guaranteed to terminate, that's what 'undecidable' means. The flag says go ahead and try until either the question is decided or the recursion stack is exhausted, whichever happens first. From duncan.coutts at worc.ox.ac.uk Thu Dec 11 11:46:58 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 11:39:56 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> Message-ID: <1229014018.10115.568.camel@localhost> On Thu, 2008-12-11 at 16:26 +0100, Sean Leather wrote: > > The above is true, but then I ran it with --optghc=-D__HADDOCK__ and > that fixed the problem. You see, I didn't know who was actually > defining the __HADDOCK__ macro. Now, after looking at code for Haddock > and Cabal, I realize it's Cabal. > > > Does Cabal 1.6.0.1 actually define this macro? I don't see it listed > when I run cabal-install with --verbose=3, but I don't know if it's > supposed to be printed. For haddock-0.x, Cabal cpp's all the modules with -D__HADDOCK__ because the old haddock cannot parse all sorts of things. However for haddock-2.x it is important not to use -D__HADDOCK__ because the hacks that people added for haddock-0.x would make haddock-2.x fail. For example they'd simply omit entire declarations. While haddock-0.x didn't really care and parsed and renamed in a sloppy way, haddoxk-2.x is basically ghc and so if the module does not compile then it also cannot be processed via haddock-2.x. The proper solution is to make haddock not fail when it encounters TH code or whatever the original problem was. It can ignore it for now, it just has to not fail. Duncan From leather at cs.uu.nl Thu Dec 11 12:20:11 2008 From: leather at cs.uu.nl (Sean Leather) Date: Thu Dec 11 12:13:07 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1229014018.10115.568.camel@localhost> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> Message-ID: <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> > For haddock-0.x, Cabal cpp's all the modules with -D__HADDOCK__ because > the old haddock cannot parse all sorts of things. > > However for haddock-2.x it is important not to use -D__HADDOCK__ because > the hacks that people added for haddock-0.x would make haddock-2.x fail. > For example they'd simply omit entire declarations. While haddock-0.x > didn't really care and parsed and renamed in a sloppy way, haddoxk-2.x > is basically ghc and so if the module does not compile then it also > cannot be processed via haddock-2.x. > That's quite a presumption there. I can certainly write a module that compiles and produces documentation for Haddock but that is different when compiled into binary form. Even without this particular problem, I can see that being potentially useful. The proper solution is to make haddock not fail when it encounters TH > code or whatever the original problem was. It can ignore it for now, it > just has to not fail. > That's certainly the ideal solution; however, it is not there right now. I would be happy to work around it if I could, but I can't. As far as I can tell, I can't pass any flags to Haddock via the Cabal file. I would love to tell Hackage to run Haddock like so, "cabal haddock --haddock-option=--optghc=-D__HADDOCK__", but I don't know how. This adventure has exposed a major problem with Cabal that I have run into several times. It supports a limited set of external tools (e.g. Haddock, Alex, Happy, etc.), but it supports them in a limited way. Primarily, it is not possible to pass options to these tools (at least) through the configure script. Also, regarding transparency with Hackage: is it possible to determine exactly which tools (e.g. Haddock version) are being used on the server? I would like to see a list on the website of the exact operations that will be applied to my package once uploaded. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/51318dea/attachment.htm From ryani.spam at gmail.com Thu Dec 11 13:22:23 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 11 13:15:20 2008 Subject: [Haskell-cafe] type error In-Reply-To: <4940B944.1060907@tcs.inf.tu-dresden.de> References: <1ff5dedc0812102249m14e0efcci9458dd5b09364853@mail.gmail.com> <4940B944.1060907@tcs.inf.tu-dresden.de> Message-ID: <2f9b2d30812111022k682b26fav72f30422a7bf5bb3@mail.gmail.com> The other simple option is to eta-expand: > let myprint x = print x will get the correct type, The monomorphism restriction is to stop things that look like *values* whose computation results are memoized, from turning into *functions* which need a dictionary context and get recomputed every time they are accessed. In your declaration, "myprint" looks like a value, so it should only get computed once. In order to do this it needs to be monomorphic, because otherwise it could have a different value depending on where it was used. -- ryan On Wed, Dec 10, 2008 at 10:55 PM, Janis Voigtlaender wrote: > Cetin Sert wrote: >> >> Hi, >> >> Why does this not function? >> >> Prelude> sequence [print 'a', print 2] >> 'a' >> 2 >> [(),()] >> *Prelude> let myprint = print* >> *Prelude> sequence [myprint 'a', myprint 2]* >> >> :1:18: >> Couldn't match expected type `()' against inferred type `Char' >> In the first argument of `myprint', namely 'a' >> In the expression: myprint 'a' >> In the first argument of `sequence', namely >> `[myprint 'a', myprint 2]' > > The problem is the monomorphism restriction: > > ~> ghci > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > Prelude> :t print > print :: (Show a) => a -> IO () > Prelude> let myprint=print > Prelude> :t myprint > myprint :: () -> IO () > Prelude> :q > Leaving GHCi. > ~> ghci -fno-monomorphism-restriction > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > Prelude> let myprint=print > Prelude> :t myprint > myprint :: (Show a) => a -> IO () > >> Can providing some type annotations (interactively in ghci or in some .hs >> file) help solve the problem? > > Yes. > > -- > Dr. Janis Voigtlaender > http://wwwtcs.inf.tu-dresden.de/~voigt/ > mailto:voigt@tcs.inf.tu-dresden.de > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Thu Dec 11 13:26:08 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Dec 11 13:19:05 2008 Subject: [Haskell-cafe] A curios monad Message-ID: <49415B40.1050600@btinternet.com> Yesterday I wrote something slightly unusual: module Storage where data Storage x instance Monad Storage run :: Storage x -> x data Key v instance Eq (Key v) instance Ord (Key v) new_key :: v -> Storage (Key v) set_key :: Key v -> v -> Storage () get_key :: Key v -> Storage (Maybe v) delete_key :: Key v -> Storage () In other words, you can store a value (of arbitrary type) under a unique key. The monad chooses what key for you, and tells you the key so you can look up or alter the value again later. Under the covers, it uses Data.Map to store stuff. I used some trickery with existential quantification and unsafeCoerce (!!) to make it work. Notice the sneaky phantom type in the key, telling the type system what type to coerce the value back to when you read it. Neat, eh? ...until I realised that somebody that somebody could generate a key in one run and then try to use it in another run. o_O Oops! But hey, until then it was working quite well. And completely pure; no IO anywhere. Ah well, just thought I'd share... (You could of course do away with the monad, but then you'd be able to manipulate the dictionary directly, and key uniqueness would be even more fragile!) From ryani.spam at gmail.com Thu Dec 11 13:38:11 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 11 13:31:07 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <49415B40.1050600@btinternet.com> References: <49415B40.1050600@btinternet.com> Message-ID: <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> Congratulations, you're halfway to reinventing ST! :) Here's the "trick" [1]: > data Storage s x > ... > data Key s v > ... Now add the extra "s" parameter to all the functions that use Storage & Key. > run :: (forall s. Storage s x) -> x Now you can't save keys between sessions; the type "s" isn't allowed to escape the "forall" on the left of the function arrow! For reference, here's a complete implementation of ST: > {-# LANGUAGE GeneralizedNewtypeDeriving, Rank2Types #-} > module ST where > import Data.IORef > import System.IO.Unsafe (unsafePerformIO) > > newtype ST s a = ST (IO a) deriving Monad > newtype STRef s a = STRef (IORef a) deriving Eq > -- magic is in the rank 2 type here, it makes the unsafePerformIO safe! > runST :: (forall s. ST s a) -> a > runST (ST m) = unsafePerformIO m > newSTRef a = ST (fmap STRef $ newIORef a) > readSTRef (STRef v) = ST (readIORef v) > writeSTRef (STRef v) a = ST (writeIORef v a) [1] "Lazy Functional State Threads", Launchbury & Peyton Jones, PLDI 1994 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.3299 On Thu, Dec 11, 2008 at 10:26 AM, Andrew Coppin wrote: > Yesterday I wrote something slightly unusual: > > > module Storage where > > data Storage x > instance Monad Storage > run :: Storage x -> x > > data Key v > instance Eq (Key v) > instance Ord (Key v) > > new_key :: v -> Storage (Key v) > set_key :: Key v -> v -> Storage () > get_key :: Key v -> Storage (Maybe v) > delete_key :: Key v -> Storage () > > > In other words, you can store a value (of arbitrary type) under a unique > key. The monad chooses what key for you, and tells you the key so you can > look up or alter the value again later. Under the covers, it uses Data.Map > to store stuff. I used some trickery with existential quantification and > unsafeCoerce (!!) to make it work. Notice the sneaky phantom type in the > key, telling the type system what type to coerce the value back to when you > read it. Neat, eh? > > ...until I realised that somebody that somebody could generate a key in one > run and then try to use it in another run. o_O > > Oops! > > But hey, until then it was working quite well. And completely pure; no IO > anywhere. > > Ah well, just thought I'd share... > > (You could of course do away with the monad, but then you'd be able to > manipulate the dictionary directly, and key uniqueness would be even more > fragile!) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Thu Dec 11 13:48:29 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Dec 11 13:41:21 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> Message-ID: <4941607D.4000907@btinternet.com> Ryan Ingram wrote: > Congratulations, you're halfway to reinventing ST! :) > Except that, AFAIK, ST doesn't provide the "hey you can store anything and retrieve it later" trick. ;-) I did however wonder if there wasn't some way I could use an extra phantom type to somehow "tag" which thread a key was generated in... but I couldn't figure out how to make it work. > Here's the "trick" [1]: > > >> data Storage s x >> ... >> data Key s v >> ... >> > > Now add the extra "s" parameter to all the functions that use Storage & Key. > > >> run :: (forall s. Storage s x) -> x >> > > Now you can't save keys between sessions; the type "s" isn't allowed > to escape the "forall" on the left of the function arrow! > Ah, I see. It sounds so easy when you already know how... :-) BTW, does anybody know how rank-N types are different from existential types? From andrewcoppin at btinternet.com Thu Dec 11 14:06:33 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Dec 11 13:59:25 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> Message-ID: <494164B9.8030202@btinternet.com> Alberto G. Corona wrote: > it is safe to use unsafeCoherce in your context? I mean, I think you > need to use instances of Data.Typeable (or some with the same > functionality) to make it safe. Like in Data.Dynamic... The *only* way for you to generate a Key value is to use the function I provide - which conviniently tags it with the type of value it's supposed to retreive. That means the type cast is guaranteed to cast it back to the type it was in the first place. ...unless you can muddle keys from other state threads up. In that case, all bets are off. I looked at using Data.Dynamic, but that only works for a few types. I wanted something that will work for *any* type. From moonlite at dtek.chalmers.se Thu Dec 11 10:18:12 2008 From: moonlite at dtek.chalmers.se (Mattias Bengtsson) Date: Thu Dec 11 14:24:21 2008 Subject: [Haskell-cafe] Memoization-question Message-ID: <1229008692.7839.14.camel@moonlite> The program below computes (f 27) almost instantly but if i replace the definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it takes around 12s to terminate. I realize this is because the original version caches results and only has to calculate, for example, (f 25) once instead of (i guess) four times. There is probably a good reason why this isn't caught by the compiler. But I'm interested in why. Anyone care to explain? > main = print (f 27) > > f 0 = 1 > f n = let f' = f (n-1) > in f' * f' (compiled with ghc --make -O2) Mattias From donnie at darthik.com Thu Dec 11 14:50:17 2008 From: donnie at darthik.com (Donnie Jones) Date: Thu Dec 11 14:43:18 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <1229008692.7839.14.camel@moonlite> References: <1229008692.7839.14.camel@moonlite> Message-ID: Hello Mattias, I think you will find this thread from the haskell-cafe mailing list quite helpful. Re: [Haskell-cafe] Memoization http://www.mail-archive.com/haskell-cafe@haskell.org/msg09924.html Also, the Haskell wiki contains comments about techniques for memoization along with references at the bottom. Haskell wiki Memoization: http://www.haskell.org/haskellwiki/Memoization Hope that helps. __ Donnie Jones On Thu, Dec 11, 2008 at 10:18 AM, Mattias Bengtsson < moonlite@dtek.chalmers.se> wrote: > The program below computes (f 27) almost instantly but if i replace the > definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it > takes around 12s to terminate. I realize this is because the original > version caches results and only has to calculate, for example, (f 25) > once instead of (i guess) four times. > There is probably a good reason why this isn't caught by the compiler. > But I'm interested in why. Anyone care to explain? > > > main = print (f 27) > > > > f 0 = 1 > > f n = let f' = f (n-1) > > in f' * f' > > (compiled with ghc --make -O2) > > Mattias > > _______________________________________________ > 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/20081211/0c222062/attachment.htm From rendel at daimi.au.dk Thu Dec 11 15:04:30 2008 From: rendel at daimi.au.dk (Tillmann Rendel) Date: Thu Dec 11 14:57:55 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <4941607D.4000907@btinternet.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> Message-ID: <4941724E.1080407@daimi.au.dk> Andrew Coppin wrote: > Except that, AFAIK, ST doesn't provide the "hey you can store anything > and retrieve it later" trick. ;-) I would say that Data.STRef does exactly that. Tillmann From daniel.is.fischer at web.de Thu Dec 11 15:09:46 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Dec 11 15:00:17 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <1229008692.7839.14.camel@moonlite> References: <1229008692.7839.14.camel@moonlite> Message-ID: <200812112109.46132.daniel.is.fischer@web.de> Am Donnerstag, 11. Dezember 2008 16:18 schrieb Mattias Bengtsson: > The program below computes (f 27) almost instantly but if i replace the > definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it > takes around 12s to terminate. I realize this is because the original > version caches results and only has to calculate, for example, (f 25) > once instead of (i guess) four times. > There is probably a good reason why this isn't caught by the compiler. > But I'm interested in why. Anyone care to explain? > > > main = print (f 27) > > > > f 0 = 1 > > f n = let f' = f (n-1) > > in f' * f' > > (compiled with ghc --make -O2) > > Mattias > Not an expert, so I may be wrong. The way you wrote your function, you made it clear to the compiler that you want sharing, so it shares. With g 0 = 1 g n = g (n-1)*g (n-1) it doesn't, because the type of g is Num t => t -> t, and you might call it with whatever weird Num type, for which sharing might be a bad idea (okay, for this specific function I don't see how I would define a Num type where sharing would be bad). If you give g a signature like g :: Int -> Int, the compiler knows that sharing is a good idea and does it (cool thing aside: with module Main where f 0 = 1 f n = let a = f (n-1) in a*a main = do print (f 27) print (g 30) g 0 = 1 g n = g (n-1)*g (n-1) main still runs instantaneously, but g n takes exponential time at the ghci prompt. That's because in main the argument of g is defaulted to Integer, so it's shared.) From bulat.ziganshin at gmail.com Thu Dec 11 15:11:56 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Dec 11 15:05:11 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <200812112109.46132.daniel.is.fischer@web.de> References: <1229008692.7839.14.camel@moonlite> <200812112109.46132.daniel.is.fischer@web.de> Message-ID: <421138264.20081211231156@gmail.com> Hello Daniel, Thursday, December 11, 2008, 11:09:46 PM, you wrote: you is almost right. but ghc don't share results of function calls despite their type. it just assumes that value of any type may use a lot of memory even if this type is trivial :) example when automatic sharing is very bad idea is: main = print (sum[1..10^10] + sum[1..10^10]) > Am Donnerstag, 11. Dezember 2008 16:18 schrieb Mattias Bengtsson: >> The program below computes (f 27) almost instantly but if i replace the >> definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it >> takes around 12s to terminate. I realize this is because the original >> version caches results and only has to calculate, for example, (f 25) >> once instead of (i guess) four times. >> There is probably a good reason why this isn't caught by the compiler. >> But I'm interested in why. Anyone care to explain? >> >> > main = print (f 27) >> > >> > f 0 = 1 >> > f n = let f' = f (n-1) >> > in f' * f' >> >> (compiled with ghc --make -O2) >> >> Mattias >> > Not an expert, so I may be wrong. > The way you wrote your function, you made it clear to the compiler that you > want sharing, so it shares. > With > g 0 = 1 > g n = g (n-1)*g (n-1) > it doesn't, because the type of g is Num t => t -> t, and you might call it > with whatever weird Num type, for which sharing might be a bad idea (okay, > for this specific function I don't see how I would define a Num type where > sharing would be bad). > If you give g a signature like g :: Int ->> Int, > the compiler knows that sharing is a good idea and does it (cool thing aside: > with > module Main where > f 0 = 1 > f n = let a = f (n-1) in a*a > main = do > print (f 27) > print (g 30) > g 0 = 1 > g n = g (n-1)*g (n-1) > main still runs instantaneously, but g n takes exponential time at the ghci > prompt. That's because in main the argument of g is defaulted to Integer, so > it's shared.) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From agocorona at gmail.com Thu Dec 11 15:19:41 2008 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Dec 11 15:12:37 2008 Subject: [Haskell-cafe] problems configuring hs-plugins 1.3.1 in windows Message-ID: I have problems compiling plugins 1.3.1 in windows at the configure phase configure: error C compiler cannot create executables I use ghc 6.8.2 I know that plugins is nor much tested under windows but I?m trying anyway. I think that this problem is very common also in Linux. I tried to find references to this error ut all of then are old (for plugins 1.2) and it is supposed to be solved. Do you have any workaround? By the way the reported compiler used is gcc Responder Responder a todos Reenviar -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/6072c2ff/attachment.htm From agocorona at gmail.com Thu Dec 11 15:25:06 2008 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Dec 11 15:18:03 2008 Subject: [Haskell-cafe] Re: problems with hs-plugins load-eval (possible bug) In-Reply-To: References: Message-ID: Workaround: duplicate all the imported files and include a different copy in each side. Another workaround: package all the files imported in both sides. Surprisingly, duplicate references do not appear when the imported files are in a package. PD: plugins adds 18 MBytes!! to the size of the executable. I suppose that this is because the ghc library. 2008/12/9 Alberto G. Corona > The duplicate definition error appears when I compile Main.hs and execute > it. But when I run it with runghc the behaviour is different. It works > well: > > runghc Main.hs > 3 > > Any idea? is this a bug of hs-plugins? it is just something expected?? > > 2008/12/6 Alberto G. Corona > >> I have a web server which load server extensions. these extensions >> eval-uate configuration files that contains code (user-editable workflow >> descriptions). The problem is that I need common definitions (inside >> imported modules) for the extensions and for the configuration files. This >> is not permitted by ha-plugins. >> >> The minimal code example are the files below. main loads eval.hs , that >> evaluate a expression. The common definitions are in Include.hs. The error >> is: >> >> *GHCi runtime linker: fatal error: I found a duplicate definition for >> symbol >> Include_sum1_srt >> whilst processing object file >> /home/magocoal/haskell/devel/votesWorkflow/src/unused/tests/Include.o >> >> This could be caused by: >> * Loading two different object files which export the same symbol >> * Specifying the same object file twice on the GHCi command line >> * An incorrect `package.conf' entry, causing some object to be >> loaded twice. >> GHCi cannot safely continue in this situation. Exiting now. Sorry. >> * >> >> >> ** >> Do you kno how to solve the problem while maintaining the functionality? >> >> -------Include.hs------- >> module Include where >> >> sum [x,y]= x+y >> >> >> ------Main.hs----- >> module Main >> where >> >> import Include >> import System.Plugins >> >> main= do >> s <-loadExec "eval.o" "mainc" >> print s >> >> loadExec:: String-> String->IO String >> loadExec file method = do >> >> mv <- load file ["."] [] method >> case mv of >> LoadSuccess mod v -> v :: IO String >> LoadFailure msg -> return $ concat msg >> >> >> >> ------------Eval.hs-------- >> >> module Eval(mainc) where >> import System.IO.Unsafe >> import System.Eval.Haskell >> >> mainc= do i <- unsafeEval_ "sum1 [1,2]" ["Include"] [] []["."] :: IO >> (Either [String] Int) >> return $ show i >> >> >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/7bf25946/attachment.htm From daniel.is.fischer at web.de Thu Dec 11 15:49:40 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Dec 11 15:40:10 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <421138264.20081211231156@gmail.com> References: <1229008692.7839.14.camel@moonlite> <200812112109.46132.daniel.is.fischer@web.de> <421138264.20081211231156@gmail.com> Message-ID: <200812112149.40977.daniel.is.fischer@web.de> Am Donnerstag, 11. Dezember 2008 21:11 schrieb Bulat Ziganshin: > Hello Daniel, > > Thursday, December 11, 2008, 11:09:46 PM, you wrote: > > you is almost right. but ghc don't share results of function calls > despite their type. it just assumes that value of any type may use a > lot of memory even if this type is trivial :) I may misunderstand you here. But if you give a type signature specifying a nice known type, I'm pretty sure ghc _does_ sharing (tried with Int -> Int and Integer -> Integer, g 200 instantaneous), at least with -O2. Without sharing, it would require 2^(n+1) - 1 calls to evaluate g n, that wouldn't be nearly as fast. Without the type signature, it must assume the worst, so it doesn't share. > > example when automatic sharing is very bad idea is: > > main = print (sum[1..10^10] + sum[1..10^10]) Depends on what is shared. Sharing the list would be a very bad idea, sharing sum [1 .. 10^10] would probably be a good idea. > > > Am Donnerstag, 11. Dezember 2008 16:18 schrieb Mattias Bengtsson: > >> The program below computes (f 27) almost instantly but if i replace the > >> definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it > >> takes around 12s to terminate. I realize this is because the original > >> version caches results and only has to calculate, for example, (f 25) > >> once instead of (i guess) four times. > >> There is probably a good reason why this isn't caught by the compiler. > >> But I'm interested in why. Anyone care to explain? > >> > >> > main = print (f 27) > >> > > >> > f 0 = 1 > >> > f n = let f' = f (n-1) > >> > in f' * f' > >> > >> (compiled with ghc --make -O2) > >> > >> Mattias > > > > Not an expert, so I may be wrong. > > The way you wrote your function, you made it clear to the compiler that > > you want sharing, so it shares. > > With > > > > g 0 = 1 > > g n = g (n-1)*g (n-1) > > > > it doesn't, because the type of g is Num t => t -> t, and you might call > > it with whatever weird Num type, for which sharing might be a bad idea > > (okay, for this specific function I don't see how I would define a Num > > type where sharing would be bad). > > If you give g a signature like > > g :: Int ->> Int, > > > the compiler knows that sharing is a good idea and does it (cool thing > > aside: with > > module Main where > > > > f 0 = 1 > > f n = let a = f (n-1) in a*a > > > > main = do > > print (f 27) > > print (g 30) > > > > g 0 = 1 > > g n = g (n-1)*g (n-1) > > > > main still runs instantaneously, but g n takes exponential time at the > > ghci prompt. That's because in main the argument of g is defaulted to > > Integer, so it's shared.) > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe From lennart at augustsson.net Thu Dec 11 15:52:41 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Dec 11 15:45:37 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <4941724E.1080407@daimi.au.dk> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <4941724E.1080407@daimi.au.dk> Message-ID: What ST doesn't provide is a delete operation, otherwise it the rest (but in a safe way). On Thu, Dec 11, 2008 at 9:04 PM, Tillmann Rendel wrote: > Andrew Coppin wrote: >> >> Except that, AFAIK, ST doesn't provide the "hey you can store anything and >> retrieve it later" trick. ;-) > > I would say that Data.STRef does exactly that. > > Tillmann > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Thu Dec 11 15:56:18 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Dec 11 15:49:26 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <200812112149.40977.daniel.is.fischer@web.de> References: <1229008692.7839.14.camel@moonlite> <200812112109.46132.daniel.is.fischer@web.de> <421138264.20081211231156@gmail.com> <200812112149.40977.daniel.is.fischer@web.de> Message-ID: <1103209477.20081211235618@gmail.com> Hello Daniel, Thursday, December 11, 2008, 11:49:40 PM, you wrote: sorry fo r noise, it seems that i know ghc worse than you > Am Donnerstag, 11. Dezember 2008 21:11 schrieb Bulat Ziganshin: >> Hello Daniel, >> >> Thursday, December 11, 2008, 11:09:46 PM, you wrote: >> >> you is almost right. but ghc don't share results of function calls >> despite their type. it just assumes that value of any type may use a >> lot of memory even if this type is trivial :) > I may misunderstand you here. But if you give a type signature specifying a > nice known type, I'm pretty sure ghc _does_ sharing (tried with Int -> Int and Integer ->> Integer, g 200 instantaneous), at least with -O2. Without > sharing, it would require 2^(n+1) - 1 calls to evaluate g n, that wouldn't be > nearly as fast. Without the type signature, it must assume the worst, so it > doesn't share. >> >> example when automatic sharing is very bad idea is: >> >> main = print (sum[1..10^10] + sum[1..10^10]) > Depends on what is shared. Sharing the list would be a very bad idea, sharing > sum [1 .. 10^10] would probably be a good idea. >> >> > Am Donnerstag, 11. Dezember 2008 16:18 schrieb Mattias Bengtsson: >> >> The program below computes (f 27) almost instantly but if i replace the >> >> definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it >> >> takes around 12s to terminate. I realize this is because the original >> >> version caches results and only has to calculate, for example, (f 25) >> >> once instead of (i guess) four times. >> >> There is probably a good reason why this isn't caught by the compiler. >> >> But I'm interested in why. Anyone care to explain? >> >> >> >> > main = print (f 27) >> >> > >> >> > f 0 = 1 >> >> > f n = let f' = f (n-1) >> >> > in f' * f' >> >> >> >> (compiled with ghc --make -O2) >> >> >> >> Mattias >> > >> > Not an expert, so I may be wrong. >> > The way you wrote your function, you made it clear to the compiler that >> > you want sharing, so it shares. >> > With >> > >> > g 0 = 1 >> > g n = g (n-1)*g (n-1) >> > >> > it doesn't, because the type of g is Num t => t -> t, and you might call >> > it with whatever weird Num type, for which sharing might be a bad idea >> > (okay, for this specific function I don't see how I would define a Num >> > type where sharing would be bad). >> > If you give g a signature like >> >> g :: Int ->> Int, >> >> > the compiler knows that sharing is a good idea and does it (cool thing >> > aside: with >> > module Main where >> > >> > f 0 = 1 >> > f n = let a = f (n-1) in a*a >> > >> > main = do >> > print (f 27) >> > print (g 30) >> > >> > g 0 = 1 >> > g n = g (n-1)*g (n-1) >> > >> > main still runs instantaneously, but g n takes exponential time at the >> > ghci prompt. That's because in main the argument of g is defaulted to >> > Integer, so it's shared.) >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From taruti at taruti.net Thu Dec 11 16:04:24 2008 From: taruti at taruti.net (Taru Karttunen) Date: Thu Dec 11 15:57:33 2008 Subject: [Haskell-cafe] Records and associated types Message-ID: <20081211210424.GA25465@taruti.net> Hello What is the correct way to transform code that uses record selection with TypeEq (like HList) to associated types? I keep running into problems with overlapping type families which is not allowed unless they match. The fundep code: class Select rec label val | rec label -> val instance TypeEq label label True => Select (Label label val :+: rest) label val instance (Select tail field val) => Select (any :+: tail) field val And a conversion attempt: class SelectT rec label where type S rec label instance TypeEq label label True => SelectT (Label label val :+: rest) label where type S (Label label val :+: rest) label = val instance (SelectT tail field) => SelectT (any :+: tail) field where type S (any :+: tail) field = S tail field which fails with: Conflicting family instance declarations: type instance S (Label label val :+: rest) label -- Defined at t.hs:19:9 type instance S (any :+: tail) field -- Defined at t.hs:23:9 How is it possible to get the TypeEq constraint into the type family? Attached is a complete example that illustrates the problem. - Taru Karttunen -------------- next part -------------- A non-text attachment was scrubbed... Name: t.hs Type: text/x-haskell Size: 1623 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/b7a932d2/t.bin From andrewcoppin at btinternet.com Thu Dec 11 16:05:36 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Dec 11 15:58:30 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <4941724E.1080407@daimi.au.dk> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <4941724E.1080407@daimi.au.dk> Message-ID: <494180A0.4090309@btinternet.com> Tillmann Rendel wrote: > Andrew Coppin wrote: >> Except that, AFAIK, ST doesn't provide the "hey you can store >> anything and retrieve it later" trick. ;-) > > I would say that Data.STRef does exactly that. That's true - but you can't transport those from place to play. (By design.) The reason I went to all the bother of implementing this strange monad is that I actually want several different monads that I can secretly transport keys between...and I couldn't figure out how to make STRef do that. From daniel.is.fischer at web.de Thu Dec 11 16:22:46 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Dec 11 16:13:15 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <1103209477.20081211235618@gmail.com> References: <1229008692.7839.14.camel@moonlite> <200812112149.40977.daniel.is.fischer@web.de> <1103209477.20081211235618@gmail.com> Message-ID: <200812112222.46803.daniel.is.fischer@web.de> Am Donnerstag, 11. Dezember 2008 21:56 schrieb Bulat Ziganshin: > Hello Daniel, > > Thursday, December 11, 2008, 11:49:40 PM, you wrote: > > sorry for noise, it seems that i know ghc worse than you If only that were true. I just know that GHC's optimiser can do some rather impressive stuff when given appropriate types, so I tried. Meanwhile, I've confirmed that it does share (for Int and Integer) with -O1 and -O2, but not with -O0, by looking at the generated core. Cheers, Daniel From andrewcoppin at btinternet.com Thu Dec 11 16:26:54 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Dec 11 16:19:45 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <494164B9.8030202@btinternet.com> <49418056.3060708@btinternet.com> Message-ID: <4941859E.4090309@btinternet.com> Alberto G. Corona wrote: > but because keys and data must be of the same type, you are restricted > to instances of Eq and Ord. Itsn?n true? > > 2008/12/11 Andrew Coppin > > > Alberto G. Corona wrote: > > Well, you have not to use typeable, but instead you need to > use instances of Eq and Ord. This is because the values and > the keys must be of the same type. this is the tradeoff. > > > Not really, no. The *keys* need Eq and Ord, but the values I'm > storing don't. The values I'm storing don't need any specific > properties at all. That's what I like about it. > > No. Keys are of type "Key v", where "v" can be anything. It's a phantom type, so it's not used for anything (except knowing what to coerce the value back to when it's looked up). "Key v" is just an alias to Int, which *is* in Eq and Ord, as required. There are no constraints on "v" at all. From patperry at stanford.edu Thu Dec 11 16:54:52 2008 From: patperry at stanford.edu (Patrick Perry) Date: Thu Dec 11 16:47:52 2008 Subject: [Haskell-cafe] unsafeThawByteArray# Message-ID: <4D45CC35-D7C1-4237-816A-A015DF8182D8@stanford.edu> I've noticed that there is no longer an "unsafeThawByteArray#" function in GHC.Prim. Looking through the darcs history, I found a patch with description: [project @ 2000-03-13 12:11:43 by simonmar] simonmar**20000313121144 Remove unsafeThawByteArray# primop (which was a no-op), and use unsafeCoerce# instead. ] Is the following code safe? data IntArray = IntArray !Int (ByteArray#) data STIntArray s = STIntArray !Int (MutableByteArray# s) unsafeThaw :: IntArray -> ST s (STIntArray s) unsafeThaw (IntArray n arr#) = ST $ \s1# -> let coerceArray :: State# s -> MutableByteArray# s coerceArray _ = unsafeCoerce# arr# marr# = coerceArray s1# marr = STIntArray n marr# in (# s1#, marr #) Thanks, Patrick From duncan.coutts at worc.ox.ac.uk Thu Dec 11 17:03:06 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 16:56:03 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> Message-ID: <1229032986.10115.574.camel@localhost> On Thu, 2008-12-11 at 18:20 +0100, Sean Leather wrote: > > For haddock-0.x, Cabal cpp's all the modules with > -D__HADDOCK__ because > the old haddock cannot parse all sorts of things. > > However for haddock-2.x it is important not to use > -D__HADDOCK__ because > the hacks that people added for haddock-0.x would make > haddock-2.x fail. > For example they'd simply omit entire declarations. While > haddock-0.x > didn't really care and parsed and renamed in a sloppy way, > haddoxk-2.x > is basically ghc and so if the module does not compile then it > also > cannot be processed via haddock-2.x. > > That's quite a presumption there. I can certainly write a module that > compiles and produces documentation for Haddock but that is different > when compiled into binary form. Even without this particular problem, > I can see that being potentially useful. Sure, but it'd have to be a different cpp flag because the existing one is used for a different purpose. > The proper solution is to make haddock not fail when it > encounters TH > code or whatever the original problem was. It can ignore it > for now, it > just has to not fail. > > That's certainly the ideal solution; however, it is not there right > now. > > I would be happy to work around it if I could, but I can't. As far as > I can tell, I can't pass any flags to Haddock via the Cabal file. I > would love to tell Hackage to run Haddock like so, "cabal haddock > --haddock-option=--optghc=-D__HADDOCK__", but I don't know how. > > This adventure has exposed a major problem with Cabal that I have run > into several times. It supports a limited set of external tools (e.g. > Haddock, Alex, Happy, etc.), but it supports them in a limited way. > Primarily, it is not possible to pass options to these tools (at > least) through the configure script. Don't you mean the other way around? It's not possible to pass extra options to these tools via the .cabal file and it's only possible via configure --$prog-options= > Also, regarding transparency with Hackage: is it possible to determine > exactly which tools (e.g. Haddock version) are being used on the > server? I would like to see a list on the website of the exact > operations that will be applied to my package once uploaded. You'd have to ask Ross about what happens on the build server. With the new hackage-server design, it will be possible for authors to upload docs they have generated themselves when the generic doc builder fails for whatever reason. Duncan From leather at cs.uu.nl Thu Dec 11 17:32:41 2008 From: leather at cs.uu.nl (Sean Leather) Date: Thu Dec 11 17:30:36 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1229032986.10115.574.camel@localhost> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <1229032986.10115.574.camel@localhost> Message-ID: <3c6288ab0812111432r10d0f3a4t4b424e3f0868fa27@mail.gmail.com> > > That's quite a presumption there. I can certainly write a module that > > compiles and produces documentation for Haddock but that is different > > when compiled into binary form. Even without this particular problem, > > I can see that being potentially useful. > > Sure, but it'd have to be a different cpp flag because the existing one > is used for a different purpose. > But what purpose does __HADDOCK__ serve if not to inform a file of code that haddock is currently processing it? Perhaps even better would be a __HADDOCK_VERSION__ definition that allows for code to work through changes in the tool. While CPP may not be the most type-safe tool in the world and definitely not ideal for text macro substitution, it does do this simple kind of job very well. > This adventure has exposed a major problem with Cabal that I have run > > into several times. It supports a limited set of external tools (e.g. > > Haddock, Alex, Happy, etc.), but it supports them in a limited way. > > Primarily, it is not possible to pass options to these tools (at > > least) through the configure script. > > Don't you mean the other way around? It's not possible to pass extra > options to these tools via the .cabal file and it's only possible via > configure --$prog-options= > Sorry, when I said configure script, I meant .cabal file. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/06dd887e/attachment.htm From ross at soi.city.ac.uk Thu Dec 11 17:46:41 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Thu Dec 11 17:39:39 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> Message-ID: <20081211224320.GA8948@soi.city.ac.uk> On Thu, Dec 11, 2008 at 06:20:11PM +0100, Sean Leather wrote: > Also, regarding transparency with Hackage: is it possible to determine > exactly which tools (e.g. Haddock version) are being used on the server? You can see which versions are used in the log of any failed build. The docs aren't built by the server, but by a simple client on another machine, which downloads the published index file and packages from the server and tries to build them. From duncan.coutts at worc.ox.ac.uk Thu Dec 11 18:15:48 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 18:08:45 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812111432r10d0f3a4t4b424e3f0868fa27@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <1229032986.10115.574.camel@localhost> <3c6288ab0812111432r10d0f3a4t4b424e3f0868fa27@mail.gmail.com> Message-ID: <1229037348.10115.580.camel@localhost> On Thu, 2008-12-11 at 23:32 +0100, Sean Leather wrote: > > > That's quite a presumption there. I can certainly write a > module that > > compiles and produces documentation for Haddock but that is > different > > when compiled into binary form. Even without this particular > problem, > > I can see that being potentially useful. > > > Sure, but it'd have to be a different cpp flag because the > existing one > is used for a different purpose. > > > But what purpose does __HADDOCK__ serve if not to inform a file of > code that haddock is currently processing it? To inform a file that haddock-0.x is currently processing it. > Perhaps even better would be a __HADDOCK_VERSION__ definition that > allows for code to work through changes in the tool. Yes, and files would have to actually test that version number. That's why we cannot just do -D__HADDOCK__=2, because existing modules just do: #ifdef __HADDOCK__ which means they would present broken code to haddock-2. > While CPP may not be the most type-safe tool in the world and > definitely not ideal for text macro substitution, it does do this > simple kind of job very well. Sure. Let's see what David thinks. If he thinks is possible to fix these kinds of things where haddock is not covering the whole GHC AST (at least to the degree where it can ignore bits it does not understand). If that's not realistic in the short term then we probably should introduce some haddock version macro so that people can workaround it. Duncan From leather at cs.uu.nl Thu Dec 11 18:22:04 2008 From: leather at cs.uu.nl (Sean Leather) Date: Thu Dec 11 18:15:00 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> Message-ID: <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> > I would be happy to work around it if I could, but I can't. As far as I can > tell, I can't pass any flags to Haddock via the Cabal file. I would love to > tell Hackage to run Haddock like so, "cabal haddock > --haddock-option=--optghc=-D__HADDOCK__", but I don't know how. > Let's suppose that I do actually want to define __HADDOCK__ for my library. Can I do this with a user-defined hook using the Cabal library? main :: IO () main = defaultMainWithHooks hooks where hooks = simpleUserHooks { haddockHook = haddockHook' } -- Define CPP __HADDOCK__ macro when running haddock. haddockHook' p l h f = do putStrLn ("f=\"" ++ show f ++ "\"") putStrLn ("f'=\"" ++ show f' ++ "\"") haddock p l (hookedPreProcessors h) f' where -- The Haddock flag to pass a flag to GHC to define the macro. *define__HADDOCK__ = ("haddock",["--optghc=-D__HADDOCK__"])* -- Add the flag to the the other flags. f' = f `mappend` emptyHaddockFlags { haddockProgramArgs = [define__HADDOCK__] } I got the value for define__HADDOCK__ from passing the "--haddock-option=--optghc=-D__HADDOCK__" flag at the command line. If I run "cabal haddock --verbose=3", I get: f="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = [], haddockHoogle = Flag False, haddockHtmlLocation = NoFlag, haddockExecutables = Flag False, haddockInternal = Flag False, haddockCss = NoFlag, haddockHscolour = Flag False, haddockHscolourCss = NoFlag, haddockDistPref = Flag "dist", haddockVerbosity = Flag Deafening}" f'="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = * [("haddock",["--optghc=-D__HADDOCK__"])]*, haddockHoogle = Flag False, haddockHtmlLocation = NoFlag, haddockExecutables = Flag False, haddockInternal = Flag False, haddockCss = NoFlag, haddockHscolour = Flag False, haddockHscolourCss = NoFlag, haddockDistPref = Flag "dist", haddockVerbosity = Flag Deafening}" [...] ("/.../haddock",["--html", ... My flag shows up in f' but not in the actual call to haddock. Thus, it doesn't work. With "cabal haddock --verbose=3 --haddock-option=--optghc=-D__HADDOCK__", I get: f="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = [* ("haddock",["--optghc=-D__HADDOCK__"])]*, haddockHoogle = Flag False, haddockHtmlLocation = NoFlag, haddockExecutables = Flag False, haddockInternal = Flag False, haddockCss = NoFlag, haddockHscolour = Flag False, haddockHscolourCss = NoFlag, haddockDistPref = Flag "dist", haddockVerbosity = Flag Deafening}" f'="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = * [("haddock",["--optghc=-D__HADDOCK__"]),("haddock",["--optghc=-D__HADDOCK__"])] *, haddockHoogle = Flag False, haddockHtmlLocation = NoFlag, haddockExecutables = Flag False, haddockInternal = Flag False, haddockCss = NoFlag, haddockHscolour = Flag False, haddockHscolourCss = NoFlag, haddockDistPref = Flag "dist", haddockVerbosity = Flag Deafening}" [...] ("/.../haddock",[*"--optghc=-D__HADDOCK__"*,"--html", ... Now, the command-line flag shows up in all 3. And, of course, it works. Is there something wrong with my hook code? Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/62b59780/attachment.htm From lrpalmer at gmail.com Thu Dec 11 18:33:50 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Dec 11 18:26:45 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <494180A0.4090309@btinternet.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <4941724E.1080407@daimi.au.dk> <494180A0.4090309@btinternet.com> Message-ID: <7ca3f0160812111533xdf175efka345537f87ef49f5@mail.gmail.com> On Thu, Dec 11, 2008 at 2:05 PM, Andrew Coppin wrote: > Tillmann Rendel wrote: > >> Andrew Coppin wrote: >> >>> Except that, AFAIK, ST doesn't provide the "hey you can store anything >>> and retrieve it later" trick. ;-) >>> >> >> I would say that Data.STRef does exactly that. >> > > That's true - but you can't transport those from place to play. (By > design.) If you could guarantee that the ID of a key is globally unique, even through different invocations of the monad (using eg. unsafePerformIO newUnique), then you could ensure type safety and allow transport of keys between different monads. However, if you did this, then your library would not be referentially transparent. Can you see how? Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081211/40e599d9/attachment.htm From claus.reinke at talk21.com Thu Dec 11 18:39:59 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Dec 11 18:32:59 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com><1228929679.10115.516.camel@localhost><3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com><1228994548.10115.544.camel@localhost><3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com><1229014018.10115.568.camel@localhost><3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com><1229032986.10115.574.camel@localhost><3c6288ab0812111432r10d0f3a4t4b424e3f0868fa27@mail.gmail.com> <1229037348.10115.580.camel@localhost> Message-ID: <1A6F9B97D777492382FD0F2F21361E7B@cr3lt> > Let's see what David thinks. If he thinks is possible to fix these kinds > of things where haddock is not covering the whole GHC AST (at least to > the degree where it can ignore bits it does not understand). If that's > not realistic in the short term then we probably should introduce some > haddock version macro so that people can workaround it. There was some related discussion here: http://trac.haskell.org/haddock/ticket/48 Claus From duncan.coutts at worc.ox.ac.uk Thu Dec 11 18:41:35 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 18:34:32 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> Message-ID: <1229038895.10115.589.camel@localhost> On Fri, 2008-12-12 at 00:22 +0100, Sean Leather wrote: > Let's suppose that I do actually want to define __HADDOCK__ for my > library. Can I do this with a user-defined hook using the Cabal > library? > > main :: IO () > main = defaultMainWithHooks hooks where > hooks = simpleUserHooks { haddockHook = haddockHook' } > > -- Define CPP __HADDOCK__ macro when running haddock. > haddockHook' p l h f = > do putStrLn ("f=\"" ++ show f ++ "\"") > putStrLn ("f'=\"" ++ show f' ++ "\"") > haddock p l (hookedPreProcessors h) f' Call the original haddockHook with the updated flags rather than the haddock command. Duncan From claus.reinke at talk21.com Thu Dec 11 18:50:54 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Dec 11 18:43:52 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com><1228929679.10115.516.camel@localhost><3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com><1228994548.10115.544.camel@localhost><3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com><1229014018.10115.568.camel@localhost><3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> Message-ID: <45432C00F730497D9F7032C9ECAE7103@cr3lt> >> I would be happy to work around it if I could, but I can't. As far as I can >> tell, I can't pass any flags to Haddock via the Cabal file. I would love to >> tell Hackage to run Haddock like so, "cabal haddock >> --haddock-option=--optghc=-D__HADDOCK__", but I don't know how. > > Let's suppose that I do actually want to define __HADDOCK__ for my library. > Can I do this with a user-defined hook using the Cabal library? You might want to define it conditionally, depending on version. Cabal supports package-version macros, and haddock installs both a package (the paths are wrong in the package description, but you can find the version number there) and an executable for itself, but the package version macros are not available in Setup.hs. Still, you might find something useful in the discussion for this ticket: Cabal should support Cabal-version-dependent Setup.hs http://hackage.haskell.org/trac/hackage/ticket/326 Claus From jason.dusek at gmail.com Thu Dec 11 18:54:20 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Dec 11 18:47:16 2008 Subject: [Haskell-cafe] Haskell project proposals reddit In-Reply-To: <873agvf3j1.fsf@malde.org> References: <20081210043420.GT5981@scytale.galois.com> <8dde104f0812100510i65440a76r42163a288f986728@mail.gmail.com> <4c44d90b0812100658hea3f4b3ob7368db9324cb6f7@mail.gmail.com> <42784f260812101600h196f5083g3fa8e8eff36eda19@mail.gmail.com> <873agvf3j1.fsf@malde.org> Message-ID: <42784f260812111554j374111c9x7583200c6218861b@mail.gmail.com> It's a nice interface for collecting comments on an idea and collecting people's level of agreement -- it does those things very well. If I had a blog, I would turn off comments and put a link to reddit at the bottom and then scrape reddit for the comments :) -- _jsn From leather at cs.uu.nl Thu Dec 11 19:01:54 2008 From: leather at cs.uu.nl (Sean Leather) Date: Thu Dec 11 18:58:40 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1229038895.10115.589.camel@localhost> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> <1229038895.10115.589.camel@localhost> Message-ID: <3c6288ab0812111601m7d7622a8o33aa5e828570ca50@mail.gmail.com> > Call the original haddockHook with the updated flags rather than the > haddock command. -- Define CPP __HADDOCK__ macro when running haddock. haddockHook' p l h f = do putStrLn ("f=\"" ++ show f ++ "\"") putStrLn ("g=\"" ++ show g ++ "\"") *haddockHook* simpleUserHooks p l h g where -- The Haddock flag to pass a flag to GHC to define the macro. define__HADDOCK__ = ("haddock",["--optghc=-D__HADDOCK__"]) -- Add the flag to the the other flags. g = f `mappend` emptyHaddockFlags { haddockProgramArgs = [define__HADDOCK__] } No change in output. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/fdc66a34/attachment.htm From leather at cs.uu.nl Thu Dec 11 19:09:40 2008 From: leather at cs.uu.nl (Sean Leather) Date: Thu Dec 11 19:06:00 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <45432C00F730497D9F7032C9ECAE7103@cr3lt> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> <45432C00F730497D9F7032C9ECAE7103@cr3lt> Message-ID: <3c6288ab0812111609l2af540d1r7008a26031ea4aca@mail.gmail.com> > Let's suppose that I do actually want to define __HADDOCK__ for my library. >> Can I do this with a user-defined hook using the Cabal library? >> > > You might want to define it conditionally, depending on version. > I certainly might! Cabal supports package-version macros, and haddock installs both > a package (the paths are wrong in the package description, but you > can find the version number there) and an executable for itself, but the > package version macros are not available in Setup.hs. > That's good to know. And I just found the documentation: http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html#cpp This sounds like it only works with package dependencies. Does it also work with Haddock as a processing tool? Still, you might find something useful in the discussion for this ticket: > > Cabal should support Cabal-version-dependent Setup.hs > http://hackage.haskell.org/trac/hackage/ticket/326 > Thanks for the tip. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/da31906c/attachment.htm From claus.reinke at talk21.com Thu Dec 11 19:19:10 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Dec 11 19:12:08 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com><1228929679.10115.516.camel@localhost><3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com><1228994548.10115.544.camel@localhost><3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com><1229014018.10115.568.camel@localhost><3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com><3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> <45432C00F730497D9F7032C9ECAE7103@cr3lt> Message-ID: <84E60CF7019E4CB8A057759FF08237F8@cr3lt> > Still, you might find something useful in the discussion for this ticket: > > Cabal should support Cabal-version-dependent Setup.hs > http://hackage.haskell.org/trac/hackage/ticket/326 or, more directly: http://www.haskell.org/pipermail/cabal-devel/2008-August/003576.html so, if you add the haddock package to your build-depends, that might give you a MIN_VERSION_haddock(_,_,_) already, without setup fiddling - Duncan? Then again, haddock depends on ghc and specific versions of other packages, so you might not want to depend on haddock.. Looks like one of those frustrating corners of packaging - haddock wants to be up to date wrt ghc, so claims not to need a macro; but it isn't complete, ghc keeps developing, so the macro that shouldn't be needed in theory would be useful in practice - cabal supports package version macros, but they aren't available everywhere, due to the way they are implemented - tools like haddock aren't tracked by cabal - it would be nice if every tool executable also installed a tool package with version/ path information (similar to ghc-paths for ghc), as that would be tracked by cabal - package version dependent settings in .cabal/Setup.hs would be useful; apart from the special case of cabal-version-dependent code in Setup.hs, perhaps something like this, to set options depending on package availability if flag(haddock2) build-depends: haddock > 2 haddock-options: -D__HADDOCK2__ only that options fields are limited to a predefined set, not including haddock? Shouldn't options fields be available for every use of .cabal, like haddocking? Claus From duncan.coutts at worc.ox.ac.uk Thu Dec 11 19:34:19 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 19:27:17 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <84E60CF7019E4CB8A057759FF08237F8@cr3lt> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> <45432C00F730497D9F7032C9ECAE7103@cr3lt> <84E60CF7019E4CB8A057759FF08237F8@cr3lt> Message-ID: <1229042059.10115.602.camel@localhost> On Fri, 2008-12-12 at 00:19 +0000, Claus Reinke wrote: > > Still, you might find something useful in the discussion for this ticket: > > > > Cabal should support Cabal-version-dependent Setup.hs > > http://hackage.haskell.org/trac/hackage/ticket/326 > > or, more directly: > > http://www.haskell.org/pipermail/cabal-devel/2008-August/003576.html > > so, if you add the haddock package to your build-depends, that > might give you a MIN_VERSION_haddock(_,_,_) already, without > setup fiddling - Duncan? Right, but it's not a good idea. > Then again, haddock depends on ghc and > specific versions of other packages, so you might not want to depend > on haddock.. A reason amongst several. > Looks like one of those frustrating corners of packaging > > - haddock wants to be up to date wrt ghc, so claims not to need > a macro; but it isn't complete, ghc keeps developing, so the macro > that shouldn't be needed in theory would be useful in practice It seems to me this is not insolvable. Haddock does get updated just to be able to build with ghc at all. All it needs is to be able to ignore bits of the ghc AST that it does not understand. I expect in practise it's a bit more subtle than that, but I'd like to hope that it isn't. > - cabal supports package version macros, but they aren't available > everywhere, due to the way they are implemented That's kind of by design. A package should not know the versions of packages it does not depend on. > - package version dependent settings in .cabal/Setup.hs would be > useful; apart from the special case of cabal-version-dependent > code in Setup.hs, perhaps something like this, to set options > depending on package availability > > if flag(haddock2) > build-depends: haddock > 2 > haddock-options: -D__HADDOCK2__ > > only that options fields are limited to a predefined set, not including > haddock? Shouldn't options fields be available for every use of > .cabal, like haddocking? The conflict here is between a notion of packages as descriptions and as active agents. In the model where packages simply describe what they are there is no need for the package itself to say what options you should use for random external tools, after all how should the package know how the user or package manager is using that tool and thus what options are appropriate in what circumstances. The active agent view says that packages get to dictate exactly what happens, to the extent of providing opaque scripts to perform those actions. We've kind of got a balance of the two. Package authors say what language features or compiler options are essential to build their code, while the user/package manager gets to decide all the configuration options and do things like pass special flags to special tools (since they're the ones invoking them and they know about the context and environment). If at all possible I would like to avoid adding arbitrary prog-options: fields into the .cabal file. I don't think it's the right balance between the package author and package builder. There is also a danger in adding lots of per-package hacks when there is a neat global solution, especially because when that global solution is implemented the per-package hacks will probably break. Duncan From ryani.spam at gmail.com Thu Dec 11 19:47:31 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 11 19:40:31 2008 Subject: [Haskell-cafe] Records and associated types In-Reply-To: <20081211210424.GA25465@taruti.net> References: <20081211210424.GA25465@taruti.net> Message-ID: <2f9b2d30812111647q567b8835k830f88bcd47694ae@mail.gmail.com> I don't think you can get a type equality comparison test into type families without additional compiler support. If you are willing to restrict your labels to type-level naturals or some other closed universe, and allow undecidable instances, you can do something like this: data Z = Z data S a = S a type family Select label record type instance Select lbl (rlbl, ty, rest) = IfEq lbl rlbl ty (Select lbl rest) type family IfEq n0 n1 t f type instance IfEq Z Z t f = t type instance IfEq Z (S n) t f = f type instance IfEq (S n) Z t f = f type instance IfEq (S n0) (S n1) t f = IfEq n0 n1 t f Better support for closed type families that allowed overlap would be quite useful. -- ryan 2008/12/11 Taru Karttunen : > Hello > > What is the correct way to transform code that uses record selection > with TypeEq (like HList) to associated types? I keep running into > problems with overlapping type families which is not allowed unless > they match. > > The fundep code: > > class Select rec label val | rec label -> val > instance TypeEq label label True => Select (Label label val :+: rest) label val > instance (Select tail field val) => Select (any :+: tail) field val > > And a conversion attempt: > > class SelectT rec label where > type S rec label > instance TypeEq label label True => SelectT (Label label val :+: rest) label where > type S (Label label val :+: rest) label = val > instance (SelectT tail field) => SelectT (any :+: tail) field where > type S (any :+: tail) field = S tail field > > which fails with: > > Conflicting family instance declarations: > type instance S (Label label val :+: rest) label > -- Defined at t.hs:19:9 > type instance S (any :+: tail) field -- Defined at t.hs:23:9 > > > How is it possible to get the TypeEq constraint into the type family? > > > Attached is a complete example that illustrates the problem. > > > - Taru Karttunen > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From duncan.coutts at worc.ox.ac.uk Thu Dec 11 20:01:36 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 19:54:32 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812111601m7d7622a8o33aa5e828570ca50@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> <1229038895.10115.589.camel@localhost> <3c6288ab0812111601m7d7622a8o33aa5e828570ca50@mail.gmail.com> Message-ID: <1229043696.10115.608.camel@localhost> On Fri, 2008-12-12 at 01:01 +0100, Sean Leather wrote: > > Call the original haddockHook with the updated flags rather > than the > haddock command. > No change in output. Ah, sorry I misread the code. This works: import Distribution.Simple import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(withPrograms)) import Distribution.Simple.Program (reconfigurePrograms) import Distribution.Verbosity (normal) main :: IO () main = defaultMainWithHooks simpleUserHooks { haddockHook = \pkg lbi h f -> do progs <- reconfigurePrograms normal [] [("haddock",["--optghc=-D__HADDOCK__"])] (withPrograms lbi) haddockHook simpleUserHooks pkg lbi { withPrograms = progs } h f } From duncan.coutts at worc.ox.ac.uk Thu Dec 11 20:19:33 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 11 20:12:29 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1229043696.10115.608.camel@localhost> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> <1229038895.10115.589.camel@localhost> <3c6288ab0812111601m7d7622a8o33aa5e828570ca50@mail.gmail.com> <1229043696.10115.608.camel@localhost> Message-ID: <1229044773.10115.611.camel@localhost> On Fri, 2008-12-12 at 01:01 +0000, Duncan Coutts wrote: > On Fri, 2008-12-12 at 01:01 +0100, Sean Leather wrote: > > > > Call the original haddockHook with the updated flags rather > > than the > > haddock command. > > > No change in output. > > Ah, sorry I misread the code. This works: Or simpler: import Distribution.Simple import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(withPrograms)) import Distribution.Simple.Program (userSpecifyArgs) main = defaultMainWithHooks simpleUserHooks { haddockHook = \pkg lbi h f -> let progs = userSpecifyArgs "haddock" ["--optghc=-D__HADDOCK__"] (withPrograms lbi) in haddockHook simpleUserHooks pkg lbi { withPrograms = progs } h f } From halomoan.donald at gmail.com Thu Dec 11 21:11:30 2008 From: halomoan.donald at gmail.com (Donald Halomoan) Date: Thu Dec 11 21:04:23 2008 Subject: [Haskell-cafe] GHC 6.10.1 for Solaris i86 Message-ID: <21bdabea0812111811h6735d02bk1f57986f403723da@mail.gmail.com> I am waiting for GHC 6.10. 1 binary for Solaris i86. Thanks. From gwern0 at gmail.com Thu Dec 11 21:17:09 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Dec 11 21:10:05 2008 Subject: [Haskell-cafe] Re: problems with hs-plugins load-eval (possible bug) In-Reply-To: References: Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 2008/12/11 Alberto G. Corona : > Workaround: duplicate all the imported files and include a different copy > in each side. > Another workaround: package all the files imported in both sides. > Surprisingly, duplicate references do not appear when the imported files are > in a package. > PD: plugins adds 18 MBytes!! to the size of the executable. I suppose that > this is because the ghc library. Yep. It's worth noting though: 1) this is true whether you go through hs-plugins or hint or raw GHC API. (Although Hint/raw API may be smaller - my Mueval binary is 13M total.) 2) You can shrink the binary a fair bit with 'strip' 3) Such binaries compress *very* well with utilities such as UPX. 4) This size may improve whenever dynamic libraries come and static linking is not the default. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklByaQACgkQvpDo5Pfl1oLlSwCfTxqZzT92ycKNjy1U3USbB53z p1QAnAg5TDO/bc38Uo0tvm7wh/jIVP+D =G6cI -----END PGP SIGNATURE----- From alexander.dunlap at gmail.com Fri Dec 12 00:06:33 2008 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu Dec 11 23:59:28 2008 Subject: [Haskell-cafe] Multi-parameter Type Class In-Reply-To: <4c44d90b0812110730m6630c54ct2ea39714fdbc8510@mail.gmail.com> References: <3CDFB8AFEA98E34CB599475AB11589C80CCB1D@EX2.ad.dcs.gla.ac.uk> <4c44d90b0812110730m6630c54ct2ea39714fdbc8510@mail.gmail.com> Message-ID: <57526e770812112106i34d278aeu37e73499e005050f@mail.gmail.com> 2008/12/11 Thomas DuBuisson : > I see Lennart answered your question. For more fun you could also do this > with TypeFamilies, which are the new hot thing in Haskell type level logic. > Since you are just getting into MPTC, FunDeps etc I figured you'd be > interested. > > ------ START CODE ------ > {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, > TypeSynonymInstances, FlexibleInstances, TypeFamilies #-} > > data Foo = Foo Bar deriving(Show) > data Bar = Bar String deriving(Show) > > -- A family of types will evaluate from one type to another. > -- Here, I chose the word 'Eval', which you could make more meaningful. > -- It is basically a function over types. > type family Eval b > > -- This is three definitions for the type function 'Eval' > type instance Eval Foo = Integer > type instance Eval Bar = String > type instance Eval [x] = [Eval x] > > -- And instead of a functional dependency > -- you have a type level function (Eval) that operates on the type 'a'. > class ZOT a where > zot :: a -> Eval a > > instance ZOT Foo where > zot x = 17 > > instance ZOT Bar where > zot x = "Eighteen" > > -- And don't forget that x must be an instance of ZOT to apply zot. > instance (ZOT x) => ZOT [x] where > zot xs = map zot xs > > main = do print $ zot $ Foo $ Bar "Blah" > print $ zot $ Bar "Blah" > print $ zot $ [Bar "Blah", Bar "Blah"] -- No map here please > ---- I don't mean to hijack the original question, but I have a question about this code. Is this the same as saying class ZOT a where type Eval a zot :: a -> Eval a and then appropriate instance declarations? Is there any reason to have the type function inside or outside of the class? Thanks, Alex From leather at cs.uu.nl Fri Dec 12 04:27:39 2008 From: leather at cs.uu.nl (Sean Leather) Date: Fri Dec 12 04:20:44 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1229044773.10115.611.camel@localhost> References: <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <3c6288ab0812111522t43a1e08ja67aeda1647ed04a@mail.gmail.com> <1229038895.10115.589.camel@localhost> <3c6288ab0812111601m7d7622a8o33aa5e828570ca50@mail.gmail.com> <1229043696.10115.608.camel@localhost> <1229044773.10115.611.camel@localhost> Message-ID: <3c6288ab0812120127l16b02f30kcd13d45ed5075011@mail.gmail.com> > > > Call the original haddockHook with the updated flags rather > > > than the > > > haddock command. > > main = defaultMainWithHooks simpleUserHooks { > haddockHook = \pkg lbi h f -> > let progs = userSpecifyArgs "haddock" ["--optghc=-D__HADDOCK__"] > (withPrograms lbi) > in haddockHook simpleUserHooks pkg lbi { withPrograms = progs } h f > } This worked. Thanks, Duncan. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/78d669a3/attachment.htm From leather at cs.uu.nl Fri Dec 12 05:12:02 2008 From: leather at cs.uu.nl (Sean Leather) Date: Fri Dec 12 05:05:05 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1228994548.10115.544.camel@localhost> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> Message-ID: <3c6288ab0812120212v24f44353x23930beaf0d18002@mail.gmail.com> > > I've been using "cabal haddock" to run haddock on my package. I also > > get the same error using haddock directly: > > > > > $ haddock -odir=tmp --debug --verbose --html > > Generics/EMGM.hs > > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing > > Have you filed a ticket for this in the haddock trac so that he doesn't > forget? > http://trac.haskell.org/haddock/ > There seemed to be perhaps one or two tickets related, but I wasn't sure if any exactly matched the issue, so I created a new one with a minimal testcase. http://trac.haskell.org/haddock/ticket/68 Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/18cb19a5/attachment.htm From martijn at van.steenbergen.nl Fri Dec 12 05:48:37 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Dec 12 05:41:31 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <49415B40.1050600@btinternet.com> References: <49415B40.1050600@btinternet.com> Message-ID: <49424185.9000401@van.steenbergen.nl> Andrew Coppin wrote: > In other words, you can store a value (of arbitrary type) under a unique > key. The monad chooses what key for you, and tells you the key so you > can look up or alter the value again later. Under the covers, it uses > Data.Map to store stuff. I used some trickery with existential > quantification and unsafeCoerce (!!) to make it work. Notice the sneaky > phantom type in the key, telling the type system what type to coerce the > value back to when you read it. Neat, eh? I did exactly that in my Yogurt project[1]. It felt dirty but in a good way, mostly because the interface was exactly what I needed. :-) > ...until I realised that somebody that somebody could generate a key in > one run and then try to use it in another run. o_O I've worried about this but I couldn't find a good code example of when this goes wrong. Can you? Without using any of the unsafeXxx functions, of course. Maybe I should build my monad on top of the ST monad if that makes things safer. Martijn. [1] http://hackage.haskell.org/packages/archive/Yogurt/0.2/doc/html/Network-Yogurt-Mud.html#5 From leather at cs.uu.nl Fri Dec 12 06:02:27 2008 From: leather at cs.uu.nl (Sean Leather) Date: Fri Dec 12 05:55:31 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812120212v24f44353x23930beaf0d18002@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812120212v24f44353x23930beaf0d18002@mail.gmail.com> Message-ID: <3c6288ab0812120302r2e291f0dg5479815fb6c43ed9@mail.gmail.com> > > I've been using "cabal haddock" to run haddock on my package. I also >> > get the same error using haddock directly: >> > >> > > $ haddock -odir=tmp --debug --verbose --html >> > Generics/EMGM.hs >> > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing >> >> Have you filed a ticket for this in the haddock trac so that he doesn't >> forget? >> http://trac.haskell.org/haddock/ >> > > There seemed to be perhaps one or two tickets related, but I wasn't sure if > any exactly matched the issue, so I created a new one with a minimal > testcase. > > http://trac.haskell.org/haddock/ticket/68 > And for anyone who later comes upon this thread seeking an answer to a similar problem, this is apparently a bug in the GHC API on which Haddock is dependent: http://hackage.haskell.org/trac/ghc/ticket/2739 Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/6433d180/attachment.htm From nominolo at googlemail.com Fri Dec 12 07:22:44 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Fri Dec 12 07:15:38 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812120302r2e291f0dg5479815fb6c43ed9@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812120212v24f44353x23930beaf0d18002@mail.gmail.com> <3c6288ab0812120302r2e291f0dg5479815fb6c43ed9@mail.gmail.com> Message-ID: <916b84820812120422q3e3096c2q6015766de0f53101@mail.gmail.com> The fromJust error is a bug, of course, however, the underlying problem is a bit more difficult: Haddock doesn't generate any code, it only typechecks. If the code uses Template Haskell, however, the typechecker will have to run Haskell code and potentially this code will have to come from a module of the same package. If the code indeed comes from the same package, fixing the fromJust error will just lead to GHCi linker error, since Haddock didn't generate any code for these. Here are a couple of solutions and non-solutions: - Detect whether a package uses TH by looking at the ghc flags and the OPTIONS pragmas. This might work in many cases, but: - We cannot generate Bytecode for all modules, because unboxed tuples and foreign exports are not supported by GHCi. This drawback would only affect a few packages, though, and cpp magic could hide the tricky parts from Haddock. - The bigger issue is security. TH can run arbitrary IO actions so, by default, we should just fail, and only enable it if the user says so. - Skip modules using TH. Won't work, because other modules may depend on those modules. We also cannot know which modules may require TH if the flag is set globally. - Disallow TH. That'll require a way to use #ifdef's to show alternative code. I guess, that's the current workaround. - Do a best-effort Renaming pass and run the typechecker without trying to resolve Splices. Lot's of work and may result to incorrect documentation, so I'm not sure it's worth it. Any other? / Thomas 2008/12/12 Sean Leather : > >>> > I've been using "cabal haddock" to run haddock on my package. I also >>> > get the same error using haddock directly: >>> > >>> > > $ haddock -odir=tmp --debug --verbose --html >>> > Generics/EMGM.hs >>> > > haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing >>> >>> Have you filed a ticket for this in the haddock trac so that he doesn't >>> forget? >>> http://trac.haskell.org/haddock/ >> >> There seemed to be perhaps one or two tickets related, but I wasn't sure >> if any exactly matched the issue, so I created a new one with a minimal >> testcase. >> >> http://trac.haskell.org/haddock/ticket/68 > > And for anyone who later comes upon this thread seeking an answer to a > similar problem, this is apparently a bug in the GHC API on which Haddock is > dependent: > > http://hackage.haskell.org/trac/ghc/ticket/2739 > > Regards, > Sean > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Push the envelope. Watch it bend. From marlowsd at gmail.com Fri Dec 12 08:57:44 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Dec 12 08:50:49 2008 Subject: [Haskell-cafe] Re: Windows vs. Linux x64 In-Reply-To: <20081126011626.GC9558@sliver.repetae.net> References: <200811250056.27632.bartek@sudety.it> <20081124225902.GG10286@scytale.galois.com> <200811252212.13647.bartek@sudety.it> <87myfnv8u0.fsf@malde.org> <20081126011626.GC9558@sliver.repetae.net> Message-ID: <49426DD8.9030605@gmail.com> John Meacham wrote: > On Tue, Nov 25, 2008 at 09:39:35PM +0100, Ketil Malde wrote: >> This corresponds to my experiences - 64 bits is slower, something I've >> ascribed to the cost of increased pointer size. > > ghc unfortunatly also uses 64 bit integers when in 64 bit mode, so the > cost paid is increased due to that as well, Also since each math > instruction needs an extra byte telling it to work on 64 bit data so the > code is less dense. Right - in the Java world they use tricks to keep pointers down to 32-bits on a 64-bit platform, e.g. by shifting pointers by a couple of bits (giving you access to 16Gb). There are a number of problems with doing this in GHC, though: - we already use those low pointer bits for encoding tag information. So perhaps we could take only one bit, giving you access to 8Gb, and lose one tag bit. - it means recompiling *everything*. It's a complete new way, so you have to make the decision to do this once and for all, or build all your libraries + RTS twice. In JITed languages they can make the choice at runtime, which makes it much easier. - it tends to be a bit platform-specific, because you need a base address in the address space for your 16Gb of memory, and different platforms lay out the address space differently. The nice thing about GHC's memory manager is that it currently has *no* dependencies on address-space layout (except in the ELF64 dynamic linker... sigh). - as usual with code-generation knobs, it multiplies the testing surface, which is something we're quite sensitive to (our surface is already on the verge of being larger than we can cope with given our resources). So my current take on this is that it isn't worth it just to get access to more memory and slightly improved performance. However, perhaps we should work on making it easier to use the 32-bit GHC on 64-bit platforms - IIRC right now you have to use something like -opta-m32 -optc-m32. Cheers, Simon From marlowsd at gmail.com Fri Dec 12 09:04:33 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Dec 12 08:57:29 2008 Subject: [Haskell-cafe] Re: Data.Array.Storable vs GC In-Reply-To: <20081126005944.GA9558@sliver.repetae.net> References: <1227620728.3207.5.camel@Congo> <20081126005944.GA9558@sliver.repetae.net> Message-ID: <49426F71.9040701@gmail.com> John Meacham wrote: > GHC has 'pinned arrays' that have this behavior. however, you probably > don't want to use them as they simply give the garbage collector less > choices about what to do possibly decreasing its efficiency. The garbage > collector already is free to not copy arrays if it feels it isn't worth > it, by pinning them you simply take away its ability to choose to do so > if it is needed. To be a little more concrete, all arrays larger than ~3k are effectively pinned in GHC right now, as in they are never copied. If the array is unboxed, then it is never traversed by the GC either, so large unboxed arrays have basically zero GC cost. There's no need for any help from the programmer, it's done automatically by the GC. For smaller arrays, as John says there's a tradeoff in whether to pin them or not. Pinning avoids copying in the GC, but might lead to fragmentation. Pinning is necessary if you want to pass the address of the memory to an FFI call at any point, which is why bytestring pins its arrays. Cheers, Simon From leather at cs.uu.nl Fri Dec 12 09:21:09 2008 From: leather at cs.uu.nl (Sean Leather) Date: Fri Dec 12 09:14:02 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <916b84820812120422q3e3096c2q6015766de0f53101@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812120212v24f44353x23930beaf0d18002@mail.gmail.com> <3c6288ab0812120302r2e291f0dg5479815fb6c43ed9@mail.gmail.com> <916b84820812120422q3e3096c2q6015766de0f53101@mail.gmail.com> Message-ID: <3c6288ab0812120621t6f7372f6re5ccbdd868b09634@mail.gmail.com> On Fri, Dec 12, 2008 at 13:22, Thomas Schilling wrote: > The fromJust error is a bug, of course, however, the underlying > problem is a bit more difficult: > > Haddock doesn't generate any code, it only typechecks. If the code > uses Template Haskell, however, the typechecker will have to run > Haskell code and potentially this code will have to come from a module > of the same package. If the code indeed comes from the same package, > fixing the fromJust error will just lead to GHCi linker error, since > Haddock didn't generate any code for these. > Thanks for enlightening us, Thomas. Here are a couple of solutions and non-solutions: [...] > Any other? What about the eventual (maybe never?) solution of collecting comments and types for Haddock after splicing in code? This is more long term, perhaps, but in the end ideal if it can be made to work. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/0d9c79f7/attachment.htm From bertram.felgenhauer at googlemail.com Fri Dec 12 09:47:34 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Fri Dec 12 09:40:35 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <1229008692.7839.14.camel@moonlite> References: <1229008692.7839.14.camel@moonlite> Message-ID: <20081212144734.GA4206@zombie.inf.tu-dresden.de> Mattias Bengtsson wrote: > The program below computes (f 27) almost instantly but if i replace the > definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it > takes around 12s to terminate. I realize this is because the original > version caches results and only has to calculate, for example, (f 25) > once instead of (i guess) four times. > There is probably a good reason why this isn't caught by the compiler. > But I'm interested in why. Anyone care to explain? GHC does "opportunistic CSE", when optimizations are enabled. See http://www.haskell.org/haskellwiki/GHC:FAQ#Does_GHC_do_common_subexpression_elimination.3F (http://tinyurl.com/33q93a) I've found it very hard to predict whether this will happen or not, from a given source code, because the optimizer will transform the program a lot and the "opportunistic CSE" rule may apply to one of the transformed versions. It's best to make sharing explicit when you need it, as you did below. > > main = print (f 27) > > > > f 0 = 1 > > f n = let f' = f (n-1) > > in f' * f' Bertram From ryani.spam at gmail.com Fri Dec 12 13:22:23 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Dec 12 13:15:15 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <49424185.9000401@van.steenbergen.nl> References: <49415B40.1050600@btinternet.com> <49424185.9000401@van.steenbergen.nl> Message-ID: <2f9b2d30812121022g726223b7k3aac63b5ab597737@mail.gmail.com> On Fri, Dec 12, 2008 at 2:48 AM, Martijn van Steenbergen wrote: > I've worried about this but I couldn't find a good code example of when this > goes wrong. Can you? Without using any of the unsafeXxx functions, of > course. > > Maybe I should build my monad on top of the ST monad if that makes things > safer. > [1] > http://hackage.haskell.org/packages/archive/Yogurt/0.2/doc/html/Network-Yogurt-Mud.html#5 Here's a simple example: runMud :: Mud a -> a runMud = flip evalState emptyMud main = do let v = runMud (mkVar "hello") let crash = runMud $ do v2 <- mkVar True -- v2 :: Var Bool res <- readVar v -- v :: Var String return res print crash -- boom! Both v2 and v are the same variable index (0), but different types. Since there's nothing preventing the variable from escaping from the first "runMud", we can import it into the second one where it fails. The key is that both use the same "initial state", so you have lost the uniqueness of variables. ST is safer, although you can make these systems just as safe with the phantom "state" type like ST does. It's also faster; variables turn directly into pointer references, instead of traversing an IntMap. But it gets kind of annoying writing all the extra "s" on your type signatures. -- ryan From cetin.sert at gmail.com Fri Dec 12 15:03:01 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Fri Dec 12 14:56:36 2008 Subject: [Haskell-cafe] gtk2hs question - derive SettingsWindow from Window Message-ID: <1ff5dedc0812121203v525ddf6djde04e33ac493f2e4@mail.gmail.com> Hi all, For a network manager of sorts I'm working on, I want to derive a SettingsWindowClass from the WindowClass present in Gtk2Hs: I want (the) instance(s) of the SettingsWindowClass to have a field to store connection settings: 1) Is it safe to do it like this? class WindowClass self ? SettingsWindowClass self where settingsWindowGetSettings :: self ? IO [ConnectionSetting] settingsWindowSetSettings :: self ? [ConnectionSetting] ? IO () newtype SettingsWindow = SettingsWindow (Window,[ConnectionSetting]) mkSettingsWindow = SettingsWindow unSettingsWindow (SettingsWindow o) = o settingsWindowNew :: IO SettingsWindow settingsWindowNew = do win ? windowNew return $ mkSettingsWindow (win,[]) 2) Is this a common practice in gtk2hs usage? 3) And will GC properly free the memory allocated for the Window object? How is this ensured, do ForeignPtr's always call delete on the underlying C ptr when they get garbage collected? Best Regards, CS -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/14b1fe42/attachment-0001.htm From martijn at van.steenbergen.nl Fri Dec 12 16:57:33 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Dec 12 16:50:26 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <2f9b2d30812121022g726223b7k3aac63b5ab597737@mail.gmail.com> References: <49415B40.1050600@btinternet.com> <49424185.9000401@van.steenbergen.nl> <2f9b2d30812121022g726223b7k3aac63b5ab597737@mail.gmail.com> Message-ID: <4942DE4D.1070109@van.steenbergen.nl> Ryan Ingram wrote: > Here's a simple example: > > runMud :: Mud a -> a > runMud = flip evalState emptyMud > > main = do > let v = runMud (mkVar "hello") > let crash = runMud $ do > v2 <- mkVar True -- v2 :: Var Bool > res <- readVar v -- v :: Var String > return res > print crash -- boom! > > Both v2 and v are the same variable index (0), but different types. > Since there's nothing preventing the variable from escaping from the > first "runMud", we can import it into the second one where it fails. > The key is that both use the same "initial state", so you have lost > the uniqueness of variables. Ah, yes, of course, thank you. :-) I was trying to break it from within the monad. Martijn. From garious at gmail.com Fri Dec 12 17:06:12 2008 From: garious at gmail.com (Greg Fitzgerald) Date: Fri Dec 12 16:59:03 2008 Subject: [Haskell-cafe] Parsec and (then?) type-check Message-ID: <1f3dc80d0812121406k761aeefcwf23a701f5eaedaf0@mail.gmail.com> Parser gurus, When you write a parser with a library like Parsec, do you typically type-check while parsing, or afterward in a separate pass? The latter is more modular, but it means labeling every element in the AST with the parser position so that you can give good error messages. Do you find the added modularity worth the hassle or just pack type-checking into the parser pass? Thanks, Greg From skynare at gmail.com Fri Dec 12 20:27:28 2008 From: skynare at gmail.com (sam lee) Date: Fri Dec 12 20:20:21 2008 Subject: [Haskell-cafe] Parsec and (then?) type-check In-Reply-To: <1f3dc80d0812121406k761aeefcwf23a701f5eaedaf0@mail.gmail.com> References: <1f3dc80d0812121406k761aeefcwf23a701f5eaedaf0@mail.gmail.com> Message-ID: <4e7aa0f80812121727m7403ca4fxcfb25e1b221544c0@mail.gmail.com> I use my type checking monad, which is separate from Parsec's monad. So, I can't think of a way to type check during parsing in Parsec's monad. Anyways, this is what I did: data Expr = ... | At SourcePos Expr SourcePos is from Parsec. Basically, my parse actions will return (At pos e). And I pass At pos e to typeCheck action. typeCheck (At pos e) = do put pos -- typeCheck is in State monad. -- in case of error, I'll pos <- get and report source position. typeCheck e typeCheck (Variable a) = do ... check out this: http://www.lipl.googlepages.com/index.html#source On Fri, Dec 12, 2008 at 5:06 PM, Greg Fitzgerald wrote: > Parser gurus, > > When you write a parser with a library like Parsec, do you typically > type-check while parsing, or afterward in a separate pass? The latter > is more modular, but it means labeling every element in the AST with > the parser position so that you can give good error messages. Do you > find the added modularity worth the hassle or just pack type-checking > into the parser pass? > > Thanks, > Greg > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From porges at porg.es Fri Dec 12 21:14:28 2008 From: porges at porg.es (George Pollard) Date: Fri Dec 12 21:07:25 2008 Subject: [Haskell-cafe] Numerics & implementing different instances of the same class Message-ID: <1229134468.6817.35.camel@porges-laptop> Is there a good way of doing this? My running example is Monoid: > class Monoid a where > operation :: a -> a -> a > identity :: a With the obvious examples on Num: > instance (Num a) => Monoid a where > operation = (+) > identity = 1 > > instance (Num a) => Monoid a where > operation = (*) > identity = 0 Of course, this won't work. I could introduce a newtype wrapper: > newtype (Num a) => MulNum a = MulNum a > newtype (Num a) => AddNum a = AddNum a > > instance (Num a) => Monoid (MulNum a) where > operation (MulNum x) (MulNum y) = MulNum (x * y) > identity = MulNum 1 > > instance (Num a) => Monoid (AddNum a) where ... -- etc However, when it comes to defining (e.g.) a Field class you have two Abelian groups over the same type, which won't work straight off: > class Field a where ... > instance (AbelianGroup a, AbelianGroup a) => Field a where ... Could try using the newtypes again: > > instance (AbelianGroup (x a), AbelianGroup (y a) => Field a where ... ... but this requires undecidable instances. I'm not even sure if it will do what I want. (For one thing it would also require an indication of which group distributes over the other, and this may restore decidability.) I'm beginning to think that the best way to do things would be to drop the newtype wrappers and include instead an additional parameter of a type-level Nat to allow multiple definitions per type. Is this a good way to do things? Has anyone else done something similar? I've taken a look at the Numeric Prelude but it seems to be doing things a bit differently. (e.g. there aren't constraints on Ring that require Monoid, etc) - George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081213/5b2b515f/attachment.bin From cetin.sert at gmail.com Fri Dec 12 21:38:09 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Fri Dec 12 21:31:02 2008 Subject: [Haskell-cafe] wlan library Message-ID: <1ff5dedc0812121838o1add95fchd74a86cd086b32a2@mail.gmail.com> Hi *^o^*, I am writing a network manager as a replacement for some broken, already existing knetworkmanager for a friend's computer. I was looking for some haskell libraries that provide access to wlan cards but could not find any on hackage. Maybe I missed something. Currently my tool is using linux the commands: modprobe, ifconfig, iwconfig, iwlist, dhclient etc.. Can a library calling external stand-alone linux commands be considered good enough as is? Or should one definitely write a wrapper around a more low-level, stable, POSIX-compliant foreign library to access and configure, control WLAN cards? I'd love to hear your comments. Best Regards, Cetin Sert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081213/033bc4c7/attachment.htm From dons at galois.com Fri Dec 12 21:41:20 2008 From: dons at galois.com (Don Stewart) Date: Fri Dec 12 21:34:04 2008 Subject: [Haskell-cafe] wlan library In-Reply-To: <1ff5dedc0812121838o1add95fchd74a86cd086b32a2@mail.gmail.com> References: <1ff5dedc0812121838o1add95fchd74a86cd086b32a2@mail.gmail.com> Message-ID: <20081213024120.GC20650@scytale.galois.com> cetin.sert: > Hi *^o^*, > > I am writing [1]a network manager as a replacement for some broken, > already existing knetworkmanager for a friend's computer. > > I was looking for some haskell libraries that provide access to wlan cards > but could not find any on hackage. Maybe I missed something. Currently my > tool is using linux the commands: modprobe, ifconfig, iwconfig, iwlist, > dhclient etc.. Can a library calling external stand-alone linux commands > be considered good enough as is? Or should one definitely write a wrapper > around a more low-level, stable, POSIX-compliant foreign library to access > and configure, control WLAN cards? I'd love to hear your comments. Hmm. For the long run, using the C FFI is probably more robust (a few less points of failure). A binding to the shell commands will be cheaper and more cheerful. Go for it! -- Don From westondan at imageworks.com Fri Dec 12 22:08:09 2008 From: westondan at imageworks.com (Dan Weston) Date: Fri Dec 12 22:01:05 2008 Subject: [Haskell-cafe] Numerics & implementing different instances of the same class In-Reply-To: <1229134468.6817.35.camel@porges-laptop> References: <1229134468.6817.35.camel@porges-laptop> Message-ID: <49432719.3050203@imageworks.com> What about something like data AddMult a b = AddMult a b class Monoid a where operation :: a -> a -> a identity :: a instance (Monoid a, Monoid b) => Monoid (AddMult a b) where operation (AddMult a1 m1) (AddMult a2 m2) = AddMult (operation a1 a2) (operation m1 m2) identity = AddMult identity identity class Commutative a where -- Nothing, this is a programmer proof obligation class Monoid a => Group a where inverse :: a -> a class (Commutative a, Group a) => AbelianGroup a where class (AbelianGroup a, AbelianGroup b) => Field a b where instance AbelianGroup a => Field a a where George Pollard wrote: > Is there a good way of doing this? My running example is Monoid: > >> class Monoid a where >> operation :: a -> a -> a >> identity :: a > > With the obvious examples on Num: > >> instance (Num a) => Monoid a where >> operation = (+) >> identity = 1 >> >> instance (Num a) => Monoid a where >> operation = (*) >> identity = 0 > > Of course, this won't work. I could introduce a newtype wrapper: > >> newtype (Num a) => MulNum a = MulNum a >> newtype (Num a) => AddNum a = AddNum a >> >> instance (Num a) => Monoid (MulNum a) where >> operation (MulNum x) (MulNum y) = MulNum (x * y) >> identity = MulNum 1 >> >> instance (Num a) => Monoid (AddNum a) where ... -- etc > > However, when it comes to defining (e.g.) a Field class you have two > Abelian groups over the same type, which won't work straight off: > >> class Field a where ... >> instance (AbelianGroup a, AbelianGroup a) => Field a where ... > > Could try using the newtypes again: >> instance (AbelianGroup (x a), AbelianGroup (y a) => Field a where ... > > ... but this requires undecidable instances. I'm not even sure if it > will do what I want. (For one thing it would also require an indication > of which group distributes over the other, and this may restore > decidability.) > > I'm beginning to think that the best way to do things would be to drop > the newtype wrappers and include instead an additional parameter of a > type-level Nat to allow multiple definitions per type. Is this a good > way to do things? > > Has anyone else done something similar? I've taken a look at the Numeric > Prelude but it seems to be doing things a bit differently. (e.g. there > aren't constraints on Ring that require Monoid, etc) > > - George > From dave at zednenem.com Fri Dec 12 22:58:00 2008 From: dave at zednenem.com (David Menendez) Date: Fri Dec 12 22:50:51 2008 Subject: [Haskell-cafe] Numerics & implementing different instances of the same class In-Reply-To: <1229134468.6817.35.camel@porges-laptop> References: <1229134468.6817.35.camel@porges-laptop> Message-ID: <49a77b7a0812121958v125b976etd06ae743b8d7a315@mail.gmail.com> 2008/12/12 George Pollard : > > However, when it comes to defining (e.g.) a Field class you have two > Abelian groups over the same type, which won't work straight off: Especially since you generally can't take the multiplicative inverse of the additive identity. > I'm beginning to think that the best way to do things would be to drop > the newtype wrappers and include instead an additional parameter of a > type-level Nat to allow multiple definitions per type. Is this a good > way to do things? That depends on what you're trying to do. I don't think this is an area where there is a single best solution. I've occasionally toyed with labeled monoid classes, like this one: class Monoid label a where unit :: label -> a mult :: label -> a -> a -> a data Plus instance (Num a) => Monoid Plus a where unit _ = 0 mult _ = (+) ... and so forth. Even here, there are several design possibilities. For example, here the label and the carrier jointly determine the operation, but you can also have the label determine the operation and the carrier. Moving on, you can then have: class (Monoid label a) => Group label a where inverse :: label -> a -> a class (Group labP a, Monoid labM a) => Ring labP labM a Of course, you now need to provide labels for all your operations. I suspect the overhead isn't worth it. > Has anyone else done something similar? I've taken a look at the Numeric > Prelude but it seems to be doing things a bit differently. (e.g. there > aren't constraints on Ring that require Monoid, etc) A couple of years ago, I suggested breaking Num into Monoid, Semiring, Group, Ring, and something else for abs and signum. Thus, class Monoid a where zero :: a (+) :: a -> a -> a class (Monoid a) => Semiring a where one :: a (*) :: a -> a -> a Semiring has laws which require one and (*) to form a monoid, so: newtype Product a = Product a instance (Semiring a) => Monoid (Product a) where zero = Product one Product x + Product y = Product (x * y) Note that the Monoid instance is now a consequence of the Semiring instance, rather than a requirement. -- Dave Menendez From stevelihn at gmail.com Fri Dec 12 23:00:59 2008 From: stevelihn at gmail.com (Steve Lihn) Date: Fri Dec 12 22:53:50 2008 Subject: [Haskell-cafe] ghc on CentOS 5 ? Message-ID: I recently got a CentOS server, but noticed that ghc rpm is not available from CentOS yum. After investigation, I found ghc is in Fedora repository, but does not make its way to EPEL, which yum on CentOS can use. ( http://download.fedora.redhat.com/pub/epel/5/x86_64/) Is there any plan to get it to EPEL? Or is there any missing piece preventing it? Thanks, Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/ed07fb46/attachment.htm From jefferson.r.heard at gmail.com Sat Dec 13 00:19:42 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sat Dec 13 00:12:33 2008 Subject: [Haskell-cafe] ghc on CentOS 5 ? In-Reply-To: References: Message-ID: <4165d3a70812122119k5fcbc966u9b5fde466e71b70@mail.gmail.com> I had luck building the latest GHC from source using the ghc 6.6 binary build to bootstrap. The 6.8+ binary builds run into a timer issue, at least on 64 bit CentOS that causes them to bork out during the configure script. 2008/12/12 Steve Lihn : > I recently got a CentOS server, but noticed that ghc rpm is not available > from CentOS yum. After investigation, I found ghc is in Fedora repository, > but does not make its way to EPEL, which yum on CentOS can use. > (http://download.fedora.redhat.com/pub/epel/5/x86_64/) > > Is there any plan to get it to EPEL? Or is there any missing piece > preventing it? > Thanks, Steve > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ori at avtalion.name Sat Dec 13 10:10:15 2008 From: ori at avtalion.name (Ori Avtalion) Date: Sat Dec 13 10:03:11 2008 Subject: [Haskell-cafe] Missing comment highlighting in vim syntax script Message-ID: <4943D057.5090002@avtalion.name> Hi all, The Haskell syntax script for vim mentions this mailing list as the maintainer. Perhaps one of you could fix this bug. Comments on the same line as import declarations don't get highlighted: import A -- This comment isn't highlighted import B {- Neither is this -} import C {- and this -} I'm using this version of the syntax file: (the only version) http://vim.svn.sourceforge.net/viewvc/vim/vim7/runtime/syntax/haskell.vim?revision=1296&view=markup Thanks, Ori From brianchina60221 at gmail.com Sat Dec 13 10:21:27 2008 From: brianchina60221 at gmail.com (brian) Date: Sat Dec 13 10:14:17 2008 Subject: [Haskell-cafe] Missing comment highlighting in vim syntax script In-Reply-To: <4943D057.5090002@avtalion.name> References: <4943D057.5090002@avtalion.name> Message-ID: <22f6a8f70812130721r3e5f5d65m6acb11d2bd51b30f@mail.gmail.com> On Sat, Dec 13, 2008 at 9:10 AM, Ori Avtalion wrote: > Comments on the same line as import declarations don't get highlighted: > import A -- This comment isn't highlighted > import B {- Neither is this -} > import C {- and > this -} I think the way vim tries to do syntax highlighting is fundamentally busted. That's why there are the problems like the ones you're talking about and a million others. I plan to use vim and work on my yi configs until I can switch. It's sad. From byorgey at seas.upenn.edu Sat Dec 13 11:30:36 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Dec 13 11:23:26 2008 Subject: [Haskell-cafe] Data.List.Split Message-ID: <20081213163036.GA8353@seas.upenn.edu> Today yet another newbie in #haskell asked about a 'split' function for lists, and I got fed up with saying 'no one can agree on the right interface so it doesn't exist, just write it yourself', because it's a really dumb answer, even if it's true. Instead of trying to get a 'split' function added to Data.List (which will never ever happen), I thought, why not create a module Data.List.Split which contains implementations of every conceivable way to split a list? Of course, people will probably still argue over what should go in such a module, what to name the various functions, etc., but hopefully we can converge on something useful. I've created a Data.List.Split page on the wiki: http://haskell.org/haskellwiki/Data.List.Split Please add code to it! Once something useful is hashed out we can upload it to hackage. Perhaps eventually some of it can be folded into the standard libraries, but this seems like a much more lightweight way to get started. -Brent From gianfranco.alongi at gmail.com Sat Dec 13 11:39:55 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Sat Dec 13 11:32:46 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: <20081213163036.GA8353@seas.upenn.edu> References: <20081213163036.GA8353@seas.upenn.edu> Message-ID: A very nice initiative I must say; although the page should contain the usual explanation for why such a split method can't be universal. That is, add the same explanation you give every time; but to the page. /Gianfranco On Sat, Dec 13, 2008 at 5:30 PM, Brent Yorgey wrote: > Today yet another newbie in #haskell asked about a 'split' function > for lists, and I got fed up with saying 'no one can agree on the right > interface so it doesn't exist, just write it yourself', because it's a > really dumb answer, even if it's true. > > Instead of trying to get a 'split' function added to Data.List (which > will never ever happen), I thought, why not create a module > Data.List.Split which contains implementations of every conceivable > way to split a list? Of course, people will probably still argue over > what should go in such a module, what to name the various functions, > etc., but hopefully we can converge on something useful. > > I've created a Data.List.Split page on the wiki: > > http://haskell.org/haskellwiki/Data.List.Split > > Please add code to it! Once something useful is hashed out we can > upload it to hackage. Perhaps eventually some of it can be folded > into the standard libraries, but this seems like a much more > lightweight way to get started. > > -Brent > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Patience is the last resort for those unable to take action From byorgey at seas.upenn.edu Sat Dec 13 11:47:55 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Dec 13 11:40:44 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: References: <20081213163036.GA8353@seas.upenn.edu> Message-ID: <20081213164755.GA9663@seas.upenn.edu> On Sat, Dec 13, 2008 at 05:39:55PM +0100, Gianfranco Alongi wrote: > A very nice initiative I must say; although the page should contain > the usual explanation for why such a split method can't be universal. > That is, add the same explanation you give every time; but to the > page. Good idea; I've added a list of possible ways to split, both to give people ideas for code to write, and to demonstrate why it's impossible to come up with one 'best' split function. vixey has already added some code, but we need more! -Brent From gianfranco.alongi at gmail.com Sat Dec 13 11:55:45 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Sat Dec 13 11:48:39 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: <20081213164755.GA9663@seas.upenn.edu> References: <20081213163036.GA8353@seas.upenn.edu> <20081213164755.GA9663@seas.upenn.edu> Message-ID: I have actually been thinking about a similar thing, but on the "group" subject. One can actually group things in many ways, such as groupBy (==) , so that groupBy (==) [1,2,1,2] should give [[1,1],[2,2]]. Of course other ideas are possible. On Sat, Dec 13, 2008 at 5:47 PM, Brent Yorgey wrote: > On Sat, Dec 13, 2008 at 05:39:55PM +0100, Gianfranco Alongi wrote: >> A very nice initiative I must say; although the page should contain >> the usual explanation for why such a split method can't be universal. >> That is, add the same explanation you give every time; but to the >> page. > > Good idea; I've added a list of possible ways to split, both to give > people ideas for code to write, and to demonstrate why it's impossible > to come up with one 'best' split function. > > vixey has already added some code, but we need more! > > -Brent > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Patience is the last resort for those unable to take action From byorgey at seas.upenn.edu Sat Dec 13 12:55:43 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Dec 13 12:48:34 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 97 - December 13, 2008 Message-ID: <20081213175543.GA17286@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20081213 Issue 97 - December 13, 2008 --------------------------------------------------------------------------- Welcome to issue 97 of HWN, a newsletter covering developments in the [1]Haskell community. Lots of neat blog posts and funny quotes this week. Don't forget to keep adding [2]haiku to the wiki, and don't miss Alex McLean (yaxu)'s [3]streaming livecoding performance tonight! Announcements Spam on HaskellWiki. Ashley Yakeley [4]asked what people would like to do about the increasing amounts of spam on the Haskell wiki, and offered some suggestions. The Timber compiler 1.0.2. Johan Nordlander [5]announced the first public release of the [6]Timber compiler. Timber is a modern language for building event-driven systems, based around the notion of reactive objects. It is also a purely functional language derived from Haskell, although with a strict evaluation semantics. To try it out, just grab the [7]timberc package on Hackage. Retrospective on 2008?. Don Stewart [8]proposed the idea of a 2008 retrospective. How would you choose the 10 best new libraries, applications, blog posts, etc. of 2008? a haskell_proposals subreddit. Jason Dusek [9]announced a [10]subreddit for Haskell library proposals. The idea is that Web 2.0 will help us to allocate our collective talents more efficiently when it comes to extensions (and perhaps clue us in when our pet project is something people really want). permutation-0.2. Patrick Perry [11]announced a [12]new version of the permutation library, which includes data types for storing permutations. It implements pure and impure types, the latter which can be modified in-place. The main utility of the library is converting between the linear representation of a permutation to a sequence of swaps. This allows, for instance, applying a permutation or its inverse to an array with O(1) memory use. Data.List.Split. Brent Yorgey [13]announced the creation of a wiki page for [14]Data.List.Split, a hypothetical module containing implementations of every conceivable way of splitting lists known to man, so we no longer have to (1) argue about the 'one true' interface for a 'split' function, or (2) be embarrassed when people ask why there isn't a split function in the standard libraries. Please add code or comments! At some point it will be uploaded as a new module to Hackage. Announcing Haskell protocol-buffers version 1.2.2. Chris Kuklewicz [15]announced new versions of [16]protocol-buffers, [17]protocol-buffers-descriptor, and [18]hprotoc. Discussion A curious monad. Andrew Coppin [19]exhibited an interesting Storage monad, which (it turns out) is similar to ST. An enlightening discussion if you want to understand how ST works and the motivation behind it. Origins of '$'. George Pollard [20]asked about the origins of the $ operator (low-precedence function application) in the standard libraries, leading to some interesting history and general discussion about notation. Blog noise [21]Haskell news from the [22]blogosphere. * Jamie Brandon: [23]Zombified GMap. Jamie is determined to get his SoC generalized map library released! * Philip Wadler: [24]Informatics 1 - Fancy Dress and Competition. * >>> Eduard - Gabriel Munteanu: [25]Learning Haskell, part 2. * Martin Sulzmann: [26]Equality, containment and intersection among regular expressions via symbolic manipulation. * Neil Mitchell: [27]mapM, mapM_ and monadic statements. * Alson Kemp: [28]A HAML parser for Haskell. * Chris Done: [29]More Haskell blogging. * Twan van Laarhoven: [30]Knight in n, part 4: tensors. Part four of Twan's enlightening series on computing knight moves. * Alex McLean: [31]Saturday night stream. All the cool kids will be watching Alex's streaming livecoding performance TONIGHT, using (among other things) a tool implemented in Haskell. * David Sankel: [32]Synchronous Events. * Lennart Augustsson: [33]The OCaml code again. * Lennart Augustsson: [34]Abstracting on, suggested solutions. * Lennart Augustsson: [35]The abstraction continues. * Conal Elliott: [36]Functional interactive behavior. * Conal Elliott: [37]Trimming inputs in functional reactive programming. * Mikael Vejdemo Johansson (Syzygy-): [38]J, or how I learned to stop worrying and love the matrix. * Conal Elliott: [39]Why classic FRP does not fit interactive behavior. * Clifford Beshers: [40]Functional Programming Marketing. * Lennart Augustsson: [41]A somewhat failed adventure in Haskell abstraction. * >>> Joey Hess: [42]haskell and xmonad. * Andy Gill: [43]The Timber compiler 1.0.2. * Manuel M T Chakravarty: [44]Not a particularly good article, but.... * >>> Chris Double: [45]Random and Binary IO using Iteratees. * >>> Chris Double: [46]Not a Tutorial on HAppS. * "FP Lunch": [47]The new GHC API. * Luke Palmer: [48]Compact data types. * Neil Mitchell: [49]F# from a Haskell perspective. * Real-World Haskell: [50]RWH Now In Store. * >>> Sebastian Fischer: [51]Constraint Functional-Logic Programming. * >>> fhtr: [52]Hexagons with Haskell. * >>> Eduard - Gabriel Munteanu: [53]Learning Haskell. * Bryan O'Sullivan: [54]Functional programmers on Twitter. * Martin Sulzmann: [55]Parallel Join Patterns with Guards and Propagation. * Martin Sulzmann: [56]Multi-set rewrite rules with guards and a parallel execution scheme. * Martin Sulzmann: [57]STM with control: Communication for retrying transactions. * Martin Sulzmann: [58]Concurrent Goal-Based Execution of Constraint Handling Rules. * >>> talkingCode: [59]Haskell, GTK and Multi-Threading. * >>> Gianfranco Alongi: [60]QuickCheck(ing) the code I C - source. Quotes of the Week * quicksilver: Baughn: glFlush? the 80s called, they want your programs back? * gwern: the best way to optimize a program is to make it lazier or stricter. * ksf: Perl is obfuscated by design, haskell is designed by obfuscation. * conal: omg -- i can print right from emacs again. praise be to Linux! * mmorrow: [I] didn't realize what it really said until after i @remembered it * blackh: Haskell is great because of all the wonderful things you can't do with it. * JustinBogner: gitit's 46 dependencies convinced me to install cabal-install, and now I couldn't be happier! * Anonymous: I'd love to explain to you how to write hello world in Haskell, but first let me introduce you to basic category theory. * lilac: @type \o-> look at my muscles forall t nice muscles. t -> nice -> muscles * ook: (:[]) * oink: <^(oo)^> * mmorrow: {-# RULES "HAI; CAN HAS STDIO?" id = unsafePerformIO (system "killall -9 breathingMachine && xeyes &" >> return id) #-} * gwern: We will be welcomed as liberators! I estimate that we will need 50000 haskellers at most and will be able to wind up the occupation quickly About the Haskell Weekly News New editions are posted to [61]the Haskell mailing list as well as to [62]the Haskell Sequence and [63]Planet Haskell. [64]RSS is also available, and headlines appear on [65]haskell.org. To help create new editions of this newsletter, please see the information on [66]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [67]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://haskell.org/haskellwiki/Haikus 3. http://yaxu.org/saturday-night-stream/ 4. http://article.gmane.org/gmane.comp.lang.haskell.general/16678 5. http://article.gmane.org/gmane.comp.lang.haskell.general/16672 6. http://timber-lang.org/ 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/timberc 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/48778 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/48721 10. http://www.reddit.com/r/haskell_proposals/ 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/48663 12. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/permutation 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/48868 14. http://haskell.org/haskellwiki/Data.List.Split 15. http://article.gmane.org/gmane.comp.lang.haskell.libraries/10406 16. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers 17. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers-descriptor 18. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hprotoc 19. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/48806 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/48622 21. http://planet.haskell.org/ 22. http://haskell.org/haskellwiki/Blog_articles 23. http://jamiiecb.blogspot.com/2008/12/zombified-gmap.html 24. http://wadler.blogspot.com/2008/12/informatics-1-functional-programming.html 25. http://eduard-munteanu.blogspot.com/2008/12/learning-haskell-part-2.html 26. http://sulzmann.blogspot.com/2008/12/equality-containment-and-intersection.html 27. http://neilmitchell.blogspot.com/2008/12/mapm-mapm-and-monadic-statements.html 28. http://www.alsonkemp.com/programming/a-haml-parser-for-haskell/ 29. http://chrisdone.com/blog/2008/12/11/More-Haskell-blogging 30. http://twan.home.fmf.nl/blog/haskell/Knight4.details 31. http://yaxu.org/saturday-night-stream/ 32. http://netsuperbrain.com/blog/posts/synchronous-events/ 33. http://augustss.blogspot.com/2008/12/ocaml-code-again-im-posting-slight.html 34. http://augustss.blogspot.com/2008/12/abstracting-on-suggested-solutions-i.html 35. http://augustss.blogspot.com/2008/12/abstraction-continues-i-got-several.html 36. http://conal.net/blog/posts/functional-interactive-behavior/ 37. http://conal.net/blog/posts/trimming-inputs-in-functional-reactive-programming/ 38. http://blog.mikael.johanssons.org/archive/2008/12/j-or-how-i-learned-to-stop-worrying-and-love-the-matrix/ 39. http://conal.net/blog/posts/why-classic-frp-does-not-fit-interactive-behavior/ 40. http://cliffordbeshers.blogspot.com/2007/11/functional-programming-marketing.html 41. http://augustss.blogspot.com/2008/12/somewhat-failed-adventure-in-haskell.html 42. http://kitenet.net/~joey/blog/entry/haskell_and_xmonad/ 43. http://blog.unsafeperformio.com/?p=32 44. http://justtesting.org/post/63809222 45. http://www.bluishcoder.co.nz/2008/12/random-and-binary-io-using-iteratees.html 46. http://www.bluishcoder.co.nz/2008/12/not-tutorial-on-happs.html 47. http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=168 48. file://localhost/home/brent/hacking/hwn/20081213.html 49. http://neilmitchell.blogspot.com/2008/12/f-from-haskell-perspective.html 50. http://www.realworldhaskell.org/blog/2008/12/06/rwh-now-in-store/ 51. http://www-ps.informatik.uni-kiel.de/~sebf/projects/cflp.html 52. http://fhtr.blogspot.com/2008/12/hexagons-with-haskell.html 53. http://eduard-munteanu.blogspot.com/2008/12/learning-haskell.html 54. http://www.serpentine.com/blog/2008/12/05/functional-programmers-on-twitter/ 55. http://sulzmann.blogspot.com/2008/12/parallel-join-patterns-with-guards-and.html 56. http://sulzmann.blogspot.com/2008/10/multi-set-rewrite-rules-with-guards-and.html 57. http://sulzmann.blogspot.com/2008/12/stm-with-control-communication-for.html 58. http://sulzmann.blogspot.com/2008/12/concurrent-goal-based-execution-of.html 59. http://talkingcode.co.uk/2008/12/02/haskell-gtk-and-multi-threading/ 60. http://writert.blogspot.com/2008/12/quickchecking-code-i-c-source.html 61. http://www.haskell.org/mailman/listinfo/haskell 62. http://sequence.complete.org/ 63. http://planet.haskell.org/ 64. http://sequence.complete.org/node/feed 65. http://haskell.org/ 66. http://haskell.org/haskellwiki/HWN 67. http://code.haskell.org/~byorgey/code/hwn/ From nbloomf at gmail.com Sat Dec 13 14:13:01 2008 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Sat Dec 13 14:05:52 2008 Subject: [Haskell-cafe] Parsec and type level numerals Message-ID: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> Hello all. I've got a puzzling Parsec problem. Perhaps the collective wisdom of haskell-cafe can point me in the right direction. I want to be able to parse a string of digits to a type level numeral as described in the Number parameterized typespaper. After fiddling with the problem for a while, I'm not convinced it's possible- it seems as though one would need to know the type of the result before parsing, but then we wouldn't need to parse in the first place. :) My first (simplified) approximation is as follows: > data Zero = Zero > data Succ a = Succ a > class Card t > instance Card Zero > instance (Card a) => Card (Succ a) > parseP :: (Card a) => Parser a > parseP = do { char '1' > ; rest <- parseP > ; return $ Succ rest > } > <|> return Zero I'd like for this to parse, for example, "111" into Succ Succ Succ Zero. Of course this doesn't work because parseP is ill-typed, but I'm not sure how to fix it. It seems that what I'm asking for is a function whose type is forall a. (Card a) => String -> a, which is problematic. Has anyone tried this before? I'm new to using Parsec and to parsing in general, so I apologize if this is a silly question. (Parsec is very impressive, by the way.) Thanks- Nathan Bloomfield University of Arkansas, Fayetteville -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081213/58e3b9e8/attachment.htm From brianchina60221 at gmail.com Sat Dec 13 14:45:58 2008 From: brianchina60221 at gmail.com (brian) Date: Sat Dec 13 14:38:48 2008 Subject: [Haskell-cafe] Parsec and type level numerals In-Reply-To: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> References: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> Message-ID: <22f6a8f70812131145n143b502ar310df49aa47a569a@mail.gmail.com> 2008/12/13 Nathan Bloomfield : > I want to be able to parse a string of digits to a type level numeral as > described in the Number parameterized types paper. Hi, I'm at UA too (bsl04). Here's a quick try. Sorry if I'm not getting what you're doing. import Text.Parsec import Text.Parsec.String data PeanoNumber = Zero | Succ PeanoNumber deriving Show parseP :: Parser PeanoNumber parseP = do char '1' rest <- parseP return $ Succ rest <|> return Zero test = parseTest parseP "111" From ryani.spam at gmail.com Sat Dec 13 14:47:29 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Dec 13 14:40:18 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <7ca3f0160812111533xdf175efka345537f87ef49f5@mail.gmail.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <4941724E.1080407@daimi.au.dk> <494180A0.4090309@btinternet.com> <7ca3f0160812111533xdf175efka345537f87ef49f5@mail.gmail.com> Message-ID: <2f9b2d30812131147g72e48c32ma52ab1cb358a5f37@mail.gmail.com> 2008/12/11 Luke Palmer : > If you could guarantee that the ID of a key is globally unique, even through > different invocations of the monad (using eg. unsafePerformIO newUnique), > then you could ensure type safety and allow transport of keys between > different monads. Well, for type-safety you don't need the entire ID of the key; you just need a globally unique type tag. This is, of course, what Data.Typeable provides. But you can also roll your own using Uniques: newtype TKey a = TKey Unique deriving Eq newTKey :: IO (TKey a) newTKey = fmap TKey newUnique castTKey :: TKey a -> TKey b -> Maybe (a -> b) castTKey (TKey u1) (TKey u2) | u1 == u2 = Just unsafeCoerce | otherwise = Nothing data Key a = Key Int (TKey a) deriving (Eq, Ord) data StoredValue = forall a. Stored (TKey a) a type StorageMap = IntMap StoredValue You then split up the program; one part generates TKeys for the types in IO; then you can use those throughout the pure rest of the program to index the types: newKey :: TKey a -> Storage (Key a) newKey ta = do ik <- getNextFreeInt return $ Key ik ta -- using MaybeT: -- newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) } -- with the appropriate Monad instance readKey :: Key a -> Storage (Maybe a) readKey (Key i t) = runMaybeT $ do Stored tx x <- MaybeT $ lookupMap i f <- MaybeT $ return (castTKey tx t) return (f x) -- exercises for the reader lookupMap :: Int -> Storage StoredValue getNextFreeInt :: Storage Int writeKey :: a -> Key a -> Storage () If you're willing to be *slightly* non-referentially transparent, you can generate the type keys at global scope: intTKey :: TKey Int intTKey = unsafePerformIO newTKey {-# NOINLINE intTKey #-} (There have been many arguments about "top level IO actions"; I don't want to get into that here!) -- ryan From ryani.spam at gmail.com Sat Dec 13 15:02:19 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Dec 13 14:55:09 2008 Subject: [Haskell-cafe] Parsec and type level numerals In-Reply-To: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> References: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> Message-ID: <2f9b2d30812131202o3883ebf7h4f2dfc077381b0c4@mail.gmail.com> You're almost there, but you have correctly determined the problem; you need to know the type of the parse result in order to parse. However, it is possible to hide the type from the parser; try writing this function instead: {-# LANGUAGE ExistentialQuantification #-} data AnyCard = forall t. Card t => AnyCard t parseP :: Parser AnyCard Now the type-level numeral is hidden in the "AnyCard" existential type. In order to use it, you need to be able to use operations that work on any instance of Card, which means the class/instance declarations you have so far aren't that useful. Emulating dependent types using existentials in Haskell is never pretty! Another option is to use a GADT to hold the type: {-# LANGUAGE GADTs, ExistentialQuantification #-} data GADTNum t where GZero :: GADTNum Zero GSucc :: GADTNum a -> GADTNum (Succ a) data AnyCard = forall t. AnyCard (GADTNum t) Now, after the parse, you can use the structure of the GADT to determine things about the existential type: isTwo :: AnyCard -> Maybe (Succ (Succ Zero)) isTwo (AnyCard (GSucc (GSucc GZero))) = Succ (Succ Zero) isTwo _ = Nothing -- ryan 2008/12/13 Nathan Bloomfield : > Hello all. I've got a puzzling Parsec problem. Perhaps the collective wisdom > of haskell-cafe can point me in the right direction. > > I want to be able to parse a string of digits to a type level numeral as > described in the Number parameterized types paper. After fiddling with the > problem for a while, I'm not convinced it's possible- it seems as though one > would need to know the type of the result before parsing, but then we > wouldn't need to parse in the first place. :) My first (simplified) > approximation is as follows: > >> data Zero = Zero >> data Succ a = Succ a > >> class Card t >> instance Card Zero >> instance (Card a) => Card (Succ a) > >> parseP :: (Card a) => Parser a >> parseP = do { char '1' >> ; rest <- parseP >> ; return $ Succ rest >> } >> <|> return Zero > > I'd like for this to parse, for example, "111" into Succ Succ Succ Zero. Of > course this doesn't work because parseP is ill-typed, but I'm not sure how > to fix it. It seems that what I'm asking for is a function whose type is > forall a. (Card a) => String -> a, which is problematic. > > Has anyone tried this before? I'm new to using Parsec and to parsing in > general, so I apologize if this is a silly question. (Parsec is very > impressive, by the way.) > > Thanks- > > Nathan Bloomfield > University of Arkansas, Fayetteville > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dave at zednenem.com Sat Dec 13 15:54:01 2008 From: dave at zednenem.com (David Menendez) Date: Sat Dec 13 15:46:50 2008 Subject: [Haskell-cafe] Parsec and type level numerals In-Reply-To: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> References: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> Message-ID: <49a77b7a0812131254o407d3e7fyb43359972a44a187@mail.gmail.com> 2008/12/13 Nathan Bloomfield : > I want to be able to parse a string of digits to a type level numeral as > described in the Number parameterized types paper. After fiddling with the > problem for a while, I'm not convinced it's possible- it seems as though one > would need to know the type of the result before parsing, but then we > wouldn't need to parse in the first place. :) This can be done with existential types. I think Oleg Kiselyov has an example somewhere of a parser that determines the type of its output from its input, but here's the basic idea: data SomeCard = forall a. (Card a) => SomeCard a Now you can define parseP :: Parser SomeCard Unfortunately, all you know about the value inside the SomeCard is that it's a member of the class Card, which may not be very helpful. Depending on how general you want to be, you can bundle more operations with SomeCard, or you can return a GADT that reflects the type-level natural at the value level. -- Dave Menendez From dave at zednenem.com Sat Dec 13 16:01:35 2008 From: dave at zednenem.com (David Menendez) Date: Sat Dec 13 15:54:24 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <4941607D.4000907@btinternet.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> Message-ID: <49a77b7a0812131301t7314dfb1m8f062900ae8f608e@mail.gmail.com> On Thu, Dec 11, 2008 at 1:48 PM, Andrew Coppin wrote: > > BTW, does anybody know how rank-N types are different from existential > types? You mean the Haskell extensions? ExistentialQuantification lets you define types such as, data SomeNum = forall a. Num a => SomeNum a RankNTypes lets you nest foralls arbitrarily deep in type signatures, callCC :: ((forall b. a -> m b) -> m a) -> m a -- this is rank-3 RankNTypes implies ExistentialQuantification (among others). -- Dave Menendez From marcot at holoscopio.com Sat Dec 13 16:04:43 2008 From: marcot at holoscopio.com (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Sat Dec 13 15:59:12 2008 Subject: [Haskell-cafe] Small haskell practical course Message-ID: <1229202283.23294.1.camel@quindinho.domain.invalid> Hello, I've presented a small practical course[0] in EMSL[1]. Any comments are welcome. 0: http://marcot.iaaeee.org/mini-curso.pdf (Portuguese only) 1: http://emsl.softwarelivre.org/ Greetings. -- marcot http://marcot.iaaeee.org/ From dons at galois.com Sat Dec 13 16:07:55 2008 From: dons at galois.com (Don Stewart) Date: Sat Dec 13 16:00:40 2008 Subject: [Haskell-cafe] Small haskell practical course In-Reply-To: <1229202283.23294.1.camel@quindinho.domain.invalid> References: <1229202283.23294.1.camel@quindinho.domain.invalid> Message-ID: <20081213210755.GD22782@scytale.galois.com> marcot: > Hello, > > I've presented a small practical course[0] in EMSL[1]. Any comments are > welcome. > > 0: http://marcot.iaaeee.org/mini-curso.pdf (Portuguese only) > 1: http://emsl.softwarelivre.org/ > Wonderful. Maybe you can add it to the .pt section of the Haskell wiki? http://haskell.org/haskellwiki/Pt/Haskell From marcot at holoscopio.com Sat Dec 13 16:37:47 2008 From: marcot at holoscopio.com (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Sat Dec 13 16:32:15 2008 Subject: [Haskell-cafe] Small haskell practical course In-Reply-To: <20081213210755.GD22782@scytale.galois.com> References: <1229202283.23294.1.camel@quindinho.domain.invalid> <20081213210755.GD22782@scytale.galois.com> Message-ID: <1229204267.23294.3.camel@quindinho.domain.invalid> Em S?b, 2008-12-13 ?s 13:07 -0800, Don Stewart escreveu: > marcot: > > Hello, > > > > I've presented a small practical course[0] in EMSL[1]. Any comments are > > welcome. > > > > 0: http://marcot.iaaeee.org/mini-curso.pdf (Portuguese only) > > 1: http://emsl.softwarelivre.org/ > > > > Wonderful. Maybe you can add it to the .pt section of the Haskell wiki? Done, thanks for the suggestion. http://haskell.org/haskellwiki/Livros_e_tutoriais -- marcot http://marcot.iaaeee.org/ From andrewcoppin at btinternet.com Sat Dec 13 18:00:49 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Dec 13 17:53:34 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <49a77b7a0812131301t7314dfb1m8f062900ae8f608e@mail.gmail.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <49a77b7a0812131301t7314dfb1m8f062900ae8f608e@mail.gmail.com> Message-ID: <49443EA1.40802@btinternet.com> David Menendez wrote: > On Thu, Dec 11, 2008 at 1:48 PM, Andrew Coppin > wrote: > >> BTW, does anybody know how rank-N types are different from existential >> types? >> > > You mean the Haskell extensions? > > ExistentialQuantification lets you define types such as, > > data SomeNum = forall a. Num a => SomeNum a > > RankNTypes lets you nest foralls arbitrarily deep in type signatures, > > callCC :: ((forall b. a -> m b) -> m a) -> m a -- this is rank-3 > > RankNTypes implies ExistentialQuantification (among others). > So how is foo :: ((forall b. a -> m b) -> m a) -> m a different from bar :: forall b. ((a -> m b) -> m a) -> m a then? From daniel.is.fischer at web.de Sat Dec 13 18:15:00 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Dec 13 18:05:22 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <49443EA1.40802@btinternet.com> References: <49415B40.1050600@btinternet.com> <49a77b7a0812131301t7314dfb1m8f062900ae8f608e@mail.gmail.com> <49443EA1.40802@btinternet.com> Message-ID: <200812140015.00850.daniel.is.fischer@web.de> Am Sonntag, 14. Dezember 2008 00:00 schrieb Andrew Coppin: > David Menendez wrote: > > On Thu, Dec 11, 2008 at 1:48 PM, Andrew Coppin > > > > wrote: > >> BTW, does anybody know how rank-N types are different from existential > >> types? > > > > You mean the Haskell extensions? > > > > ExistentialQuantification lets you define types such as, > > > > data SomeNum = forall a. Num a => SomeNum a > > > > RankNTypes lets you nest foralls arbitrarily deep in type signatures, > > > > callCC :: ((forall b. a -> m b) -> m a) -> m a -- this is rank-3 > > > > RankNTypes implies ExistentialQuantification (among others). > > So how is > > foo :: ((forall b. a -> m b) -> m a) -> m a Here, the argument of foo's argument must be a polymorphic function, capable of returning an (m b) whatever b is. > > different from > > bar :: forall b. ((a -> m b) -> m a) -> m a Here, the argument of bar's argument can have any monomorphic type (a -> m b) > > then? > From ryani.spam at gmail.com Sat Dec 13 22:43:41 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Dec 13 22:36:29 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <49443EA1.40802@btinternet.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <49a77b7a0812131301t7314dfb1m8f062900ae8f608e@mail.gmail.com> <49443EA1.40802@btinternet.com> Message-ID: <2f9b2d30812131943x7f026cd6sbf5aac348adb1119@mail.gmail.com> On Sat, Dec 13, 2008 at 3:00 PM, Andrew Coppin wrote: > So how is > foo :: ((forall b. a -> m b) -> m a) -> m a > different from > bar :: forall b. ((a -> m b) -> m a) -> m a Lets use a simpler example: > foo :: (forall a. a -> a) -> (Int, String) > bar :: forall a. (a -> a) -> (Int, String) > -- this compiles > foo f = (f 1, f "hello") > -- this does not compile > -- bar f = (f 1, f "hello") > -- but this does > bar f = (1, "hello") The difference is that the *caller* of bar chooses how to instantiate a, whereas the caller of foo must pass in a polymorphic function that foo can instantiate at whatever type it wants... even multiple different types! > ident x = x > plus1 x = x + 1 :: Int > -- legal > useFoo = foo ident > -- not legal, not polymorphic > -- useFoo = foo plus1 > -- legal > useBar = bar ident > -- also legal, instantiate "a" in the type of "bar" with "Int" > useBar2 = bar plus1 -- ryan From vogt.adam at gmail.com Sun Dec 14 00:35:02 2008 From: vogt.adam at gmail.com (Adam Vogt) Date: Sun Dec 14 00:27:52 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: References: <20081213163036.GA8353@seas.upenn.edu> <20081213164755.GA9663@seas.upenn.edu> Message-ID: <20081214053502.GA12106@nixos.uwaterloo.ca> * On Saturday, December 13 2008, Gianfranco Alongi wrote: >I have actually been thinking about a similar thing, but on the "group" subject. >One can actually group things in many ways, such as groupBy (==) , so >that groupBy (==) [1,2,1,2] should give >[[1,1],[2,2]]. Of course other ideas are possible. That result happens with: > sortedGroups = group . sort That composition is pretty, unlike those splitting functions. I don't know if manually fusing sort and group helps performance at all though. Making groups by comparing with the previous element, or the first element of the current group is occasionally useful: (this does the former) > groupIncDiff :: (a -> a -> Bool) -> [a] -> [[a]] > groupIncDiff p = uncurry (:) . foldr w ([],[]) > where w n ([],a) = ([n],a) > w n ((x:xs),a) | p x n = (n:x:xs,a) > | otherwise = ([n],(x:xs):a) (in case somebody feels like assembling the apparently numerous was to group) On another note, is there much use of such simple library functions: does concatMap, for instance, save anything other than a couple parantheses, or does (concat . map) not necessarily get optimized into the same thing? Adam From porges at porg.es Sun Dec 14 01:46:58 2008 From: porges at porg.es (George Pollard) Date: Sun Dec 14 01:39:52 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: <20081214053502.GA12106@nixos.uwaterloo.ca> References: <20081213163036.GA8353@seas.upenn.edu> <20081213164755.GA9663@seas.upenn.edu> <20081214053502.GA12106@nixos.uwaterloo.ca> Message-ID: <1229237218.7077.3.camel@porges-laptop> On Sun, 2008-12-14 at 00:35 -0500, Adam Vogt wrote: > On another note, is there much use of such simple library functions: does > concatMap, for instance, save anything other than a couple parantheses, or > does (concat . map) not necessarily get optimized into the same thing Bart Massey?s results suggest very little difference: http://wiki.cs.pdx.edu/forge/concatmap.html (Yellow blobs + green crosses.) - George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081214/2cb77f64/attachment.bin From porges at porg.es Sun Dec 14 01:51:12 2008 From: porges at porg.es (George Pollard) Date: Sun Dec 14 01:44:06 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: <1229237218.7077.3.camel@porges-laptop> References: <20081213163036.GA8353@seas.upenn.edu> <20081213164755.GA9663@seas.upenn.edu> <20081214053502.GA12106@nixos.uwaterloo.ca> <1229237218.7077.3.camel@porges-laptop> Message-ID: <1229237472.7077.5.camel@porges-laptop> On Sun, 2008-12-14 at 19:46 +1300, George Pollard wrote: > On Sun, 2008-12-14 at 00:35 -0500, Adam Vogt wrote: > > On another note, is there much use of such simple library functions: does > > concatMap, for instance, save anything other than a couple parantheses, or > > does (concat . map) not necessarily get optimized into the same thing > > Bart Massey?s results suggest very little difference: > http://wiki.cs.pdx.edu/forge/concatmap.html > > (Yellow blobs + green crosses.) I should have said that, on the other hand, with stream fusion enabled, (concat . map) outperforms (concatMap) :) - George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081214/792ecfa3/attachment.bin From dave at zednenem.com Sun Dec 14 02:50:28 2008 From: dave at zednenem.com (David Menendez) Date: Sun Dec 14 02:43:15 2008 Subject: [Haskell-cafe] A curios monad In-Reply-To: <49443EA1.40802@btinternet.com> References: <49415B40.1050600@btinternet.com> <2f9b2d30812111038p6aca86ccj70cdbe7cf06f6196@mail.gmail.com> <4941607D.4000907@btinternet.com> <49a77b7a0812131301t7314dfb1m8f062900ae8f608e@mail.gmail.com> <49443EA1.40802@btinternet.com> Message-ID: <49a77b7a0812132350w46528c4bp11bc923c628c6b15@mail.gmail.com> On Sat, Dec 13, 2008 at 6:00 PM, Andrew Coppin wrote: > David Menendez wrote: >> >> On Thu, Dec 11, 2008 at 1:48 PM, Andrew Coppin >> wrote: >> >>> >>> BTW, does anybody know how rank-N types are different from existential >>> types? >>> >> >> You mean the Haskell extensions? >> >> ExistentialQuantification lets you define types such as, >> >> data SomeNum = forall a. Num a => SomeNum a >> >> RankNTypes lets you nest foralls arbitrarily deep in type signatures, >> >> callCC :: ((forall b. a -> m b) -> m a) -> m a -- this is rank-3 >> >> RankNTypes implies ExistentialQuantification (among others). >> > > So how is > > foo :: ((forall b. a -> m b) -> m a) -> m a > > different from > > bar :: forall b. ((a -> m b) -> m a) -> m a > > then? Daniel Fischer already gave the short answer, I'll try explaining why someone might *want* a rank-3 signature for callCC. It involves a continuation monad, but hopefully nothing headache-inducing. The type for callCC in Control.Monad.Cont.Class is, callCC :: forall m a b. (MonadCont m) => ((a -> m b) -> m b) -> m b You can use callCC to do very complicated things, but you can also use it as a simple short-cut escape, like the way "return" works in C. foo = callCC (\exit -> do ... x <- if something then return 'a' else exit False ... return True) The type of exit is Bool -> m Char, which is fine in this example, but it means that we can only use exit to escape from computations that are producing characters. For example, we cannot write, bar = callCC (\exit -> do ... x <- if something then return 'a' else exit False y <- if something then return 42 else exit False ... return True) Because exit would need to have the type Bool -> m Char the first time and Bool -> m Int the second time. But, if callCC had a rank-3 type, callCC :: forall m a. (MonadCont m) => ((forall b. a -> m b) -> m a) -> m a then exit would have the type "forall b. Bool -> m b", and bar would compile just fine. -- Dave Menendez From dan.doel at gmail.com Sun Dec 14 12:13:44 2008 From: dan.doel at gmail.com (Dan Doel) Date: Sun Dec 14 12:06:35 2008 Subject: [Haskell-cafe] ANNOUNCE: uvector-algorithms 0.1 Message-ID: <200812141213.45057.dan.doel@gmail.com> Hello, I've been sitting on this for a while, waiting for some changes to uvector to go in, but finally decided I should just release it, and fix it up if and when said changes go in. So, I'm announcing the first release of uvector- algorithms. What it is is a library of algorithms (mostly sorting) for the mutable arrays defined in uvector. It has several varieties of sorting, including introsort (quicksort which falls back on heapsort in bad cases), heapsort, a simple top- down merge sort and a radix sort (as well as insertion sort, and optimal sorting for length<=4 arrays, which probably won't get much use outside of the implementation of the other sorts). All modules attempt to export as uniform an interface as possible, so that one can substitute between them freely, say when trying to determine which algorithm is best suited for your particular datasets. Also exposed are the operations that allow you to use the arrays as heaps (which is the basis for implementing heapsort), and partial sorts and selects in heap and intro variety. Lastly, there is a combinator for safely using these mutable array algorithms to sort immutable arrays. All of these algorithms have been painstakingly profiled, and their generated core examined to do as little heap allocation and as much unboxing as possible, and to inline and specialize for maximum performance (unless, of course, I've managed to miss anything). I've been running a relatively simple benchmarking suite that tests various kinds of inputs, and in my experience, the sorts herein tend to beat glibc's sort, and do relatively well compared to GNU's STL sorts over vector<>s (taking 50% or so more time at present, although this library may well be better at heapsorting random arrays, if you want something to brag about :)). For future work, I've been working on an implementation of Python's timsort (which is a very fancy bottom-up merge sort), but it's not ready yet. I'd also like to introduce some combinators for easy Schwartzian transforms, but that again requires modifications to uvector. I may also look at moving some of my benchmark program into the package. Suggestions for other algorithms people would like to see are of course welcome (especially if accompanied by papers/references on how to implement them if they're not well known). The hackage page is here: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uvector-algorithms Enjoy, and please let me know of any issues. -- Dan From matti.niemenmaa+news at iki.fi Sun Dec 14 12:39:03 2008 From: matti.niemenmaa+news at iki.fi (Matti Niemenmaa) Date: Sun Dec 14 12:32:02 2008 Subject: [Haskell-cafe] Re: Data.List.Split In-Reply-To: <20081214053502.GA12106@nixos.uwaterloo.ca> References: <20081213163036.GA8353@seas.upenn.edu> <20081213164755.GA9663@seas.upenn.edu> <20081214053502.GA12106@nixos.uwaterloo.ca> Message-ID: Adam Vogt wrote: > * On Saturday, December 13 2008, Gianfranco Alongi wrote: >> I have actually been thinking about a similar thing, but on the "group" subject. >> One can actually group things in many ways, such as groupBy (==) , so >> that groupBy (==) [1,2,1,2] should give >> [[1,1],[2,2]]. Of course other ideas are possible. > > That result happens with: > >> sortedGroups = group . sort > > That composition is pretty, unlike those splitting functions. I don't know > if manually fusing sort and group helps performance at all though. Sorting requires an Ord instance, though. Here's a relatively simple but slow way which doesn't: fullGroupBy :: (a -> a -> Bool) -> [a] -> [[a]] fullGroupBy rel xs = map (\a -> filter (rel a) xs) (nubBy rel xs) From claus.reinke at talk21.com Sun Dec 14 13:04:35 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Sun Dec 14 12:57:26 2008 Subject: [Haskell-cafe] Missing comment highlighting in vim syntax script References: <4943D057.5090002@avtalion.name> Message-ID: <19CBC89695044E9D98F7CA4C946A789E@cr3lt> > The Haskell syntax script for vim mentions this mailing list as the > maintainer. Perhaps one of you could fix this bug. > Comments on the same line as import declarations don't get highlighted: I don't know how this list-as-maintainer idea is going to work, but the fix seems straightforward: find the line in $VIMRUNTIME/syntax/haskell.vim that says syn match hsImport "\.*"he=s+6 contains=hsImportMod and change it to syn match hsImport "\.*"he=s+6 contains=hsImportMod,hsLineComment,hsBlockComment See :help syn-contains. Claus From dons at galois.com Sun Dec 14 16:15:04 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 14 16:07:43 2008 Subject: [Haskell-cafe] Time for a new logo? Message-ID: <20081214211504.GO27904@scytale.galois.com> I noticed a new haskell logo idea on a tshirt today, http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png Simple, clean and *pure*. Instead of the "we got lots going on" of the current logo. Any graphic designers want to try some variations on this theme of purity? A new year, and a new mature logo... -- Don From johan.tibell at gmail.com Sun Dec 14 16:27:43 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Dec 14 16:20:30 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <90889fe70812141327if02a189xa46997e2813363c2@mail.gmail.com> On Sun, Dec 14, 2008 at 10:15 PM, Don Stewart wrote: > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > Simple, clean and *pure*. I like it. I prefer the thick lambda over the script one and the circle provides nice framing. I'm no graphics designer though. Cheers, Johan From porges at porg.es Sun Dec 14 16:37:36 2008 From: porges at porg.es (George Pollard) Date: Sun Dec 14 16:30:28 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <90889fe70812141327if02a189xa46997e2813363c2@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <90889fe70812141327if02a189xa46997e2813363c2@mail.gmail.com> Message-ID: <1229290656.11108.1.camel@porges-laptop> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/98459918/attachment.bin From skynare at gmail.com Sun Dec 14 16:50:11 2008 From: skynare at gmail.com (sam lee) Date: Sun Dec 14 16:42:58 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <1229290656.11108.1.camel@porges-laptop> References: <20081214211504.GO27904@scytale.galois.com> <90889fe70812141327if02a189xa46997e2813363c2@mail.gmail.com> <1229290656.11108.1.camel@porges-laptop> Message-ID: <4e7aa0f80812141350w39e60922o20457ca813ac81b1@mail.gmail.com> http://i35.tinypic.com/mjon83.png used this: http://www.simwebsol.com/ImageTool/Default.aspx 2008/12/14 George Pollard : > ? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From brianchina60221 at gmail.com Sun Dec 14 17:26:13 2008 From: brianchina60221 at gmail.com (brian) Date: Sun Dec 14 17:18:59 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <22f6a8f70812141426w4ce7d412u625b338283254634@mail.gmail.com> On Sun, Dec 14, 2008 at 3:15 PM, Don Stewart wrote: > I noticed a new haskell logo idea on a tshirt today, > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png I'd buy one, but I'm not seeing it on spreadshirt.net. From dons at galois.com Sun Dec 14 17:29:21 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 14 17:22:02 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <22f6a8f70812141426w4ce7d412u625b338283254634@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <22f6a8f70812141426w4ce7d412u625b338283254634@mail.gmail.com> Message-ID: <20081214222921.GP27904@scytale.galois.com> brianchina60221: > On Sun, Dec 14, 2008 at 3:15 PM, Don Stewart wrote: > > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > I'd buy one, but I'm not seeing it on spreadshirt.net. http://haskell.org/haskellwiki/Merchandise ? From ketil at malde.org Sun Dec 14 17:35:13 2008 From: ketil at malde.org (Ketil Malde) Date: Sun Dec 14 17:27:56 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> (Don Stewart's message of "Sun\, 14 Dec 2008 13\:15\:04 -0800") References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <87iqpmbd26.fsf@malde.org> Don Stewart writes: > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > Simple, clean and *pure*. Nice. For some more hubris, replace 'A' with 'The'. -k -- If I haven't seen further, it is by standing in the footprints of giants From dons at galois.com Sun Dec 14 17:38:14 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 14 17:30:51 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <87iqpmbd26.fsf@malde.org> References: <20081214211504.GO27904@scytale.galois.com> <87iqpmbd26.fsf@malde.org> Message-ID: <20081214223814.GQ27904@scytale.galois.com> ketil: > Don Stewart writes: > > > I noticed a new haskell logo idea on a tshirt today, > > > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > > > Simple, clean and *pure*. > > Nice. For some more hubris, replace 'A' with 'The'. I had the very same thought :) Stamp it home. From allbery at ece.cmu.edu Sun Dec 14 17:53:20 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Dec 14 17:46:18 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <4e7aa0f80812141350w39e60922o20457ca813ac81b1@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <90889fe70812141327if02a189xa46997e2813363c2@mail.gmail.com> <1229290656.11108.1.camel@porges-laptop> <4e7aa0f80812141350w39e60922o20457ca813ac81b1@mail.gmail.com> Message-ID: <89F017A1-BA06-4C30-89BB-4F7C213E9BF6@ece.cmu.edu> On 2008 Dec 14, at 16:50, sam lee wrote: > http://i35.tinypic.com/mjon83.png > used this: http://www.simwebsol.com/ImageTool/Default.aspx Win from the "visually interesting" angle, but massive lose from the "legibility" angle. -- 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 jgmorris at cecs.pdx.edu Sun Dec 14 17:59:17 2008 From: jgmorris at cecs.pdx.edu (J. Garrett Morris) Date: Sun Dec 14 17:52:12 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214223814.GQ27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> <87iqpmbd26.fsf@malde.org> <20081214223814.GQ27904@scytale.galois.com> Message-ID: <6cf91caa0812141459v69ac165dwfb1645d26fda4745@mail.gmail.com> On Sun, Dec 14, 2008 at 2:38 PM, Don Stewart wrote: > ketil: >> Nice. For some more hubris, replace 'A' with 'The'. > > I had the very same thought :) It certainly wouldn't do to let, say, the existence of Concurrent Clean get in the way of our self-promotion. /g -- I am in here From lennart at augustsson.net Sun Dec 14 18:47:25 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Sun Dec 14 18:40:10 2008 Subject: [Haskell-cafe] ANN: typehash version 1.3 Message-ID: The typehash library allows you to produce a unique identifier (a cryptographic hash) for a type. This is useful if you save values of some type to a file (text, binary, whatever format you wish) and then when you read it back in again you want to verify that the type you want to read is the one you actually wrote. The type hash takes into account both the actual name of the type and the structure of the type. The type hash is a compact value that only allows comparing for equality. The library also supports type codes. A type code encodes the complete structure of a type and can be used for finer comparison than just equality, e.g., will the read function be able to read what show produced (in this case renaming types and adding constructors is allowed). The library is on hackage, of course. -- Lennart From derek.a.elkins at gmail.com Sun Dec 14 18:52:14 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Dec 14 18:45:10 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <1228774553.8548.22.camel@otto.ehbuehl.net> References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> <1228774553.8548.22.camel@otto.ehbuehl.net> Message-ID: <1229298734.6354.13.camel@derek-laptop> On Mon, 2008-12-08 at 23:15 +0100, Joachim Breitner wrote: > Hi, > > Am Montag, den 08.12.2008, 15:59 -0600 schrieb Nathan Bloomfield: > > > Slightly off topic, but the A^B notation for hom-sets also makes the > > natural isomorphism we call currying expressable as A^(BxC) = (A^B)^C. > > So A^(B+C) = A^B ? A^C ? > > Oh, right, I guess that?s actually true: > > uncurry either :: (a -> c, b -> c) -> (Either a b -> c) > (\f -> (f . Left, f . Right)) :: (Either a b -> c) -> (a -> c, b -> c) > > It?s always nice to see that I havn?t learned the elementary power > calculation rules for nothing :-) I want to point out a quick categorical way of proving this (and almost all the other "arithmetic" laws follow similarly.) This is just continuity of right adjoints. The interesting thing is the adjunction, one that is commonly neglected in discussions of Cartesian closed categories. A^- is a function C^{op} -> C and it is adjoint to itself on the right, i.e. (A^-)^{op} -| A^-. As an isomorphism of hom functors that is, Hom(=,A^-) ~ Hom(-,A^=) or in Haskell notation there is an isomorphism flip :: (a -> b -> c) -> (b -> a -> c) (it is it's own inverse.) This is induced by the swap operation on pairs and is why for enriched categories usually they talk about -symmetric- monoidally closed categories. Symmetric monoidally closed categories validate all the arithmetic laws as well. So B+C is BxC in the opposite category and so A^- takes (BxC)^op to A^B x A^C. And that's not all, every adjunction gives rise to a monad namely, A^(A^-) or in Haskell notation (b -> a) -> a and indeed if you work out the details this is the continuation monad. From ok at cs.otago.ac.nz Sun Dec 14 18:59:12 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Dec 14 18:52:06 2008 Subject: [Haskell-cafe] Origins of '$' In-Reply-To: <1229298734.6354.13.camel@derek-laptop> References: <1228620603.22033.4.camel@porges-laptop> <625b74080812081036g49641e3dk44cccf9fc7ded9d7@mail.gmail.com> <9858b5620812081359x39b90666gcf5efab55d7302e8@mail.gmail.com> <1228774553.8548.22.camel@otto.ehbuehl.net> <1229298734.6354.13.camel@derek-laptop> Message-ID: <63E81194-2900-402D-97AF-56C0E9DF9FFA@cs.otago.ac.nz> On 15 Dec 2008, at 12:52 pm, Derek Elkins wrote: > I want to point out a quick categorical way of proving this (and > almost > all the other "arithmetic" laws follow similarly.) This is just > continuity of right adjoints. The interesting thing is the > adjunction, > one that is commonly neglected in discussions of Cartesian closed > categories. December buds swell. Categories unlimit Haskell I once knew. From eelco at lempsink.nl Sun Dec 14 20:57:02 2008 From: eelco at lempsink.nl (Eelco Lempsink) Date: Sun Dec 14 20:49:54 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/5628006e/PGP.bin From dons at galois.com Sun Dec 14 21:27:17 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 14 21:19:56 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> References: <20081214211504.GO27904@scytale.galois.com> <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> Message-ID: <20081215022717.GB28801@scytale.galois.com> eelco: > On 14 dec 2008, at 22:15, Don Stewart wrote: > >I noticed a new haskell logo idea on a tshirt today, > > > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > > >Simple, clean and *pure*. > > > >Instead of the "we got lots going on" of the current logo. > > > >Any graphic designers want to try some variations on this theme of > >purity? > > > I'm not a graphic designer, but that doesn't prevent me giving a try. > > > > (Transparant PNG, for best results view on a white background.) > > By the way, the font used (Kautiva) is not free. You might recognize > it from Tupil's logo ;) > Could you attach it to the web page, http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas -- Don From derek.a.elkins at gmail.com Sun Dec 14 21:31:37 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Dec 14 21:24:29 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> References: <20081214211504.GO27904@scytale.galois.com> <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> Message-ID: <1229308297.6354.14.camel@derek-laptop> On Mon, 2008-12-15 at 02:57 +0100, Eelco Lempsink wrote: > On 14 dec 2008, at 22:15, Don Stewart wrote: > > I noticed a new haskell logo idea on a tshirt today, > > > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > > > Simple, clean and *pure*. > > > > Instead of the "we got lots going on" of the current logo. > > > > Any graphic designers want to try some variations on this theme of > > purity? > > > I'm not a graphic designer, but that doesn't prevent me giving a try. > > > (Transparant PNG, for best results view on a white background.) > > By the way, the font used (Kautiva) is not free. You might recognize > it from Tupil's logo ;) Someone would pay for that font? It literally hurts my eyes. From coreyoconnor at gmail.com Sun Dec 14 21:36:09 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Sun Dec 14 21:28:54 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <1229290656.11108.1.camel@porges-laptop> References: <20081214211504.GO27904@scytale.galois.com> <90889fe70812141327if02a189xa46997e2813363c2@mail.gmail.com> <1229290656.11108.1.camel@porges-laptop> Message-ID: I like the proposed logo even more now that you've pointed out the similarity. :-) -Corey O'Connor 2008/12/14 George Pollard : > ? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From gasbeing at gmail.com Sun Dec 14 22:02:42 2008 From: gasbeing at gmail.com (Thomas Fee) Date: Sun Dec 14 21:57:52 2008 Subject: [Haskell-cafe] Re: ghc on CentOS 5 ? References: <4165d3a70812122119k5fcbc966u9b5fde466e71b70@mail.gmail.com> Message-ID: > Jeff Heard gmail.com> writes: > > I had luck building the latest GHC from source using the ghc 6.6 > binary build to bootstrap. The 6.8+ binary builds run into a timer > issue, at least on 64 bit CentOS that causes them to bork out during > the configure script. > > 2008/12/12 Steve Lihn gmail.com>: > > I recently got a CentOS server, but noticed that ghc rpm is not available > > from CentOS yum. After investigation, I found ghc is in Fedora repository, > > but does not make its way to EPEL, which yum on CentOS can use. > > (http://download.fedora.redhat.com/pub/epel/5/x86_64/) > > > > Is there any plan to get it to EPEL? Or is there any missing piece > > preventing it? > > Thanks, Steve I don't understand this. I went to http://download.fedora.redhat.com/pub/epel/5/x86_64/ and did not see ghc. I thought ghc is there for fedora but not for centos. And Jeff is saying that one may as well just build it from source? From mblazevic at stilo.com Sun Dec 14 22:17:25 2008 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Sun Dec 14 22:10:10 2008 Subject: [Haskell-cafe] Multi-parameter type class woes Message-ID: <.1229311045@magma.ca> I have, for a change, a relatively simple problem with type classes. Can somebody explain to me, or point me to an explanation of the behaviour I see? Here is a short and useless example: {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} import Data.Maybe class Container x y where wrapper :: x -> Bool unwrap :: x -> y rewrap :: y -> x liftWrap :: Container x y => (y -> y) -> (x -> x) liftWrap f x = (if wrapper x then rewrap . f . unwrap else id) x instance Container (Maybe x) x where wrapper = isJust unwrap = fromJust rewrap = Just main = print (liftWrap (succ :: Int -> Int) (Just 1 :: Maybe Int)) GHC 6.10.1 refuses to typecheck the 'wrapper' function in definition of 'liftWrap', with the following error message: Could not deduce (Container x y) from the context (Container x y1) arising from a use of `wrapper' at Test.hs:11:22-30 Possible fix: add (Container x y) to the context of the type signature for `liftWrap' In the expression: wrapper x In the expression: (if wrapper x then rewrap . f . unwrap else id) x In the definition of `liftWrap': liftWrap f x = (if wrapper x then rewrap . f . unwrap else id) x Let me clarify that I'm aware that in this particular example a functional dependecy should be used. Also, I can think of a few workarounds for my actual problem, so I'm not asking for any solutions. I'm looking for an explanation. It bugs me that my intuition of how this type class should have worked is completely wrong. The error message does not help, to put it mildly. Where should I go, what should I read? From lane at downstairspeople.org Sun Dec 14 22:46:21 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Sun Dec 14 22:39:09 2008 Subject: [Haskell-cafe] Multi-parameter type class woes In-Reply-To: <.1229311045@magma.ca> References: <.1229311045@magma.ca> Message-ID: I'll take a swing at this one: instance Container (Maybe x) [x] where wrapper = isNothing . . . That isn't a sensible definition of 'wrapper', but I believe without trying to compile it is completely legal. Which wrapper do you use? You /don't/ have a different matching Container instance, but without the functional dependency you /might/, and ghc barfs. --L On Sun, 14 Dec 2008, Mario Bla?evi? wrote: > I have, for a change, a relatively simple problem with type classes. Can somebody explain to me, or point me to an explanation of the behaviour I see? > > Here is a short and useless example: > > {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} > > import Data.Maybe > > class Container x y where > wrapper :: x -> Bool > unwrap :: x -> y > rewrap :: y -> x > > liftWrap :: Container x y => (y -> y) -> (x -> x) > liftWrap f x = (if wrapper x then rewrap . f . unwrap else id) x > > instance Container (Maybe x) x where > wrapper = isJust > unwrap = fromJust > rewrap = Just > > main = print (liftWrap (succ :: Int -> Int) (Just 1 :: Maybe Int)) > > GHC 6.10.1 refuses to typecheck the 'wrapper' function in definition of 'liftWrap', with the following error message: > > Could not deduce (Container x y) from the context (Container x y1) > arising from a use of `wrapper' at Test.hs:11:22-30 > Possible fix: > add (Container x y) to the context of > the type signature for `liftWrap' > In the expression: wrapper x > In the expression: > (if wrapper x then rewrap . f . unwrap else id) x > In the definition of `liftWrap': > liftWrap f x = (if wrapper x then rewrap . f . unwrap else id) x > > Let me clarify that I'm aware that in this particular example a functional dependecy should be used. Also, I can think of a few workarounds for my actual problem, so I'm not asking for any solutions. I'm looking for an explanation. It bugs me that my intuition of how this type class should have worked is completely wrong. The error message does not help, to put it mildly. Where should I go, what should I read? > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mblazevic at stilo.com Sun Dec 14 23:10:00 2008 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Sun Dec 14 23:02:44 2008 Subject: [Haskell-cafe] Multi-parameter type class woes Message-ID: <.1229314200@magma.ca> > I'll take a swing at this one: > > instance Container (Maybe x) [x] where > wrapper = isNothing > . . . > > That isn't a sensible definition of 'wrapper', but I believe without > trying to compile it is completely legal. Which wrapper do you use? > > You /don't/ have a different matching Container instance, but without the > functional dependency you /might/, and ghc barfs. But liftWrap doesn't require any particular instance, it's a generic function accepting any pair of types for which there is an instance of Container. Instance selection (as I understand it) shouldn't come into play until one applies liftWrap to a particular type, and indeed it does cause problems there: note the type annotations on the last line. That part I understand and accept, or at least have learned to live with. > On Sun, 14 Dec 2008, Mario Bla?evi? wrote: > >> I have, for a change, a relatively simple problem with >> type classes. Can somebody explain to me, or point me to an explanation of >> the behaviour I see? >> >> Here is a short and useless example: >> >> {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} >> >> import Data.Maybe >> >> class Container x y where >> wrapper :: x -> Bool >> unwrap :: x -> y >> rewrap :: y -> x >> >> liftWrap :: Container x y => (y -> y) -> (x -> x) >> liftWrap f x = (if wrapper x then rewrap . f . unwrap else id) x >> >> instance Container (Maybe x) x where >> wrapper = isJust >> unwrap = fromJust >> rewrap = Just >> >> main = print (liftWrap (succ :: Int -> Int) (Just 1 :: Maybe Int)) >> >> GHC 6.10.1 refuses to typecheck the 'wrapper' function >> in definition of 'liftWrap', with the following error message: >> >> Could not deduce (Container x y) from the context (Container x y1) >> arising from a use of `wrapper' at Test.hs:11:22-30 >> Possible fix: >> add (Container x y) to the context of >> the type signature for `liftWrap' >> In the expression: wrapper x >> In the expression: >> (if wrapper x then rewrap . f . unwrap else id) x >> In the definition of `liftWrap': >> liftWrap f x = (if wrapper x then rewrap . f . unwrap else id) x >> >> Let me clarify that I'm aware that in this particular >> example a functional dependecy should be used. Also, I can think of a few >> workarounds for my actual problem, so I'm not asking for any solutions. I'm >> looking for an explanation. It bugs me that my intuition of how this type >> class should have worked is completely wrong. The error message does not >> help, to put it mildly. Where should I go, what should I read? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From alexander.dunlap at gmail.com Sun Dec 14 23:45:15 2008 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Dec 14 23:38:00 2008 Subject: [Haskell-cafe] Multi-parameter type class woes In-Reply-To: <.1229314200@magma.ca> References: <.1229314200@magma.ca> Message-ID: <57526e770812142045w255fb42bwb882e435f2fa61eb@mail.gmail.com> On Sun, Dec 14, 2008 at 8:10 PM, Mario Bla?evi? wrote: >> I'll take a swing at this one: >> >> instance Container (Maybe x) [x] where >> wrapper = isNothing >> . . . >> >> That isn't a sensible definition of 'wrapper', but I believe without >> trying to compile it is completely legal. Which wrapper do you use? >> >> You /don't/ have a different matching Container instance, but without the >> functional dependency you /might/, and ghc barfs. > > > But liftWrap doesn't require any particular instance, it's a > generic function accepting any pair of types for which there is > an instance of Container. Instance selection (as I understand it) > shouldn't come into play until one applies liftWrap to a > particular type, and indeed it does cause problems there: note > the type annotations on the last line. That part I understand > and accept, or at least have learned to live with. The problem is that y is not mentioned in the signature of wrapper. When you call wrapper x, there could be many different instances of Container x y with the same x, so GHC doesn't know which version to call. You can fix this problem either by adding a functional dependency or by splitting wrapper out into its own class (Wrapper x, e.g.) so all of the type variables in the class head are mentioned in its type and the instance can be determined by the call. Thanks for asking this question, by the way. I had known about this issue but had never really realized why it happened. Now that I have thought about it, I understand it too. :) Hope that helps, Alex From lane at downstairspeople.org Sun Dec 14 23:51:04 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Sun Dec 14 23:44:07 2008 Subject: [Haskell-cafe] Multi-parameter type class woes In-Reply-To: <.1229314200@magma.ca> References: <.1229314200@magma.ca> Message-ID: On Sun, 14 Dec 2008, Mario Bla?evi? wrote: >> I'll take a swing at this one: >> >> instance Container (Maybe x) [x] where >> wrapper = isNothing >> . . . >> >> That isn't a sensible definition of 'wrapper', but I believe without >> trying to compile it is completely legal. Which wrapper do you use? >> >> You /don't/ have a different matching Container instance, but without the >> functional dependency you /might/, and ghc barfs. > > > But liftWrap doesn't require any particular instance, it's a > generic function accepting any pair of types for which there is > an instance of Container. Instance selection (as I understand it) > shouldn't come into play until one applies liftWrap to a > particular type, and indeed it does cause problems there: note > the type annotations on the last line. That part I understand > and accept, or at least have learned to live with. Yes, that is an intuitive understanding to us humans, but the instance selection applies seperately for 'wrapper' and 'listWrap'; ghc doesn't automatically prefer a particular instance just because it is in the context of the calling function. --L From clifford.beshers at gmail.com Mon Dec 15 00:05:07 2008 From: clifford.beshers at gmail.com (Clifford Beshers) Date: Sun Dec 14 23:57:52 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081215022717.GB28801@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> <20081215022717.GB28801@scytale.galois.com> Message-ID: <6841b9520812142105u2e0e1635n7f2a0940620c1c04@mail.gmail.com> On Sun, Dec 14, 2008 at 6:27 PM, Don Stewart wrote: > > Could you attach it to the web page, > > http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas > > I tossed up a quickie candidate there as well. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081214/a7e47807/attachment.htm From ketil at malde.org Mon Dec 15 02:49:29 2008 From: ketil at malde.org (Ketil Malde) Date: Mon Dec 15 02:42:12 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <6cf91caa0812141459v69ac165dwfb1645d26fda4745@mail.gmail.com> (J. Garrett Morris's message of "Sun\, 14 Dec 2008 14\:59\:17 -0800") References: <20081214211504.GO27904@scytale.galois.com> <87iqpmbd26.fsf@malde.org> <20081214223814.GQ27904@scytale.galois.com> <6cf91caa0812141459v69ac165dwfb1645d26fda4745@mail.gmail.com> Message-ID: <874p15c1yu.fsf@malde.org> "J. Garrett Morris" writes: >>> Nice. For some more hubris, replace 'A' with 'The'. >> I had the very same thought :) > It certainly wouldn't do to let, say, the existence of Concurrent > Clean get in the way of our self-promotion. Well, they get to make T-shirts with "Clean - the /other/ purely functional language". Seriously though - thet text can be interpreted as Haskell, the purely functional language to distinguish it from Haskell, the county in Texas, or Haskell, the Indian Nations University....or for that matter Haskell, the logician. To avoid any hard feelings, I suggest either putting "Haskell the logician" (with a picture of same) on the back of the shirt, or replacing the text with just "purely functional" or similar. At any rate, "A" is to weak, and suggests just one of the crowd. -k -- If I haven't seen further, it is by standing in the footprints of giants From reiner.pope at gmail.com Mon Dec 15 02:59:42 2008 From: reiner.pope at gmail.com (Reiner Pope) Date: Mon Dec 15 02:52:27 2008 Subject: [Haskell-cafe] Parsec and type level numerals In-Reply-To: <49a77b7a0812131254o407d3e7fyb43359972a44a187@mail.gmail.com> References: <9858b5620812131113x85fac6jfb1f923fb994254e@mail.gmail.com> <49a77b7a0812131254o407d3e7fyb43359972a44a187@mail.gmail.com> Message-ID: <4cf038ee0812142359q596aa6a4ped71a2f4f2f11b98@mail.gmail.com> On Sun, Dec 14, 2008 at 6:54 AM, David Menendez wrote: > 2008/12/13 Nathan Bloomfield : >> I want to be able to parse a string of digits to a type level numeral as >> described in the Number parameterized types paper. After fiddling with the >> problem for a while, I'm not convinced it's possible- it seems as though one >> would need to know the type of the result before parsing, but then we >> wouldn't need to parse in the first place. :) > > This can be done with existential types. I think Oleg Kiselyov has an > example somewhere of a parser that determines the type of its output > from its input, but here's the basic idea: > > data SomeCard = forall a. (Card a) => SomeCard a > > Now you can define parseP :: Parser SomeCard > > Unfortunately, all you know about the value inside the SomeCard is > that it's a member of the class Card, which may not be very helpful. > Depending on how general you want to be, you can bundle more > operations with SomeCard, or you can return a GADT that reflects the > type-level natural at the value level. > > -- > Dave Menendez > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Depending on what you actually want to do, you may be looking for Oleg Kiselyov's reifyIntegral function, which he defines in the paper "Functional Pearl: Implicit Configurations -- or Type Classes Reflect the Value of Types" (at http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf ). It has type something like reifyIntegral :: forall a. Int -> (forall n. Numeral n => n -> a) -> a encoding n's existential type with continuation passing style. Cheers, Reiner From ndmitchell at gmail.com Mon Dec 15 03:40:44 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Dec 15 03:33:29 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: <1229237472.7077.5.camel@porges-laptop> References: <20081213163036.GA8353@seas.upenn.edu> <20081213164755.GA9663@seas.upenn.edu> <20081214053502.GA12106@nixos.uwaterloo.ca> <1229237218.7077.3.camel@porges-laptop> <1229237472.7077.5.camel@porges-laptop> Message-ID: <404396ef0812150040v5c9dc796ge79d3265ae949bbc@mail.gmail.com> Hi > I should have said that, on the other hand, with stream fusion enabled, > (concat . map) outperforms (concatMap) :) That can only be a bug in stream fusion - concatMap should always be prefered! Thanks Neil From tom.davie at gmail.com Mon Dec 15 03:43:05 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Dec 15 03:35:51 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081215022717.GB28801@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> <20081215022717.GB28801@scytale.galois.com> Message-ID: On 15 Dec 2008, at 03:27, Don Stewart wrote: > Could you attach it to the web page, > > http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas I've stuck a contender up there too. Bob From david.waern at gmail.com Mon Dec 15 03:55:18 2008 From: david.waern at gmail.com (David Waern) Date: Mon Dec 15 03:48:04 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <3c6288ab0812120621t6f7372f6re5ccbdd868b09634@mail.gmail.com> References: <3c6288ab0812100630i7ee64b3di17a54e7005278a09@mail.gmail.com> <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812120212v24f44353x23930beaf0d18002@mail.gmail.com> <3c6288ab0812120302r2e291f0dg5479815fb6c43ed9@mail.gmail.com> <916b84820812120422q3e3096c2q6015766de0f53101@mail.gmail.com> <3c6288ab0812120621t6f7372f6re5ccbdd868b09634@mail.gmail.com> Message-ID: 2008/12/12 Sean Leather : > On Fri, Dec 12, 2008 at 13:22, Thomas Schilling wrote: >> >> The fromJust error is a bug, of course, however, the underlying >> problem is a bit more difficult: >> >> Haddock doesn't generate any code, it only typechecks. If the code >> uses Template Haskell, however, the typechecker will have to run >> Haskell code and potentially this code will have to come from a module >> of the same package. If the code indeed comes from the same package, >> fixing the fromJust error will just lead to GHCi linker error, since >> Haddock didn't generate any code for these. > > Thanks for enlightening us, Thomas. > >> Here are a couple of solutions and non-solutions: > > [...] > >> >> Any other? > > What about the eventual (maybe never?) solution of collecting comments and > types for Haddock after splicing in code? This is more long term, perhaps, > but in the end ideal if it can be made to work. This is what Haddock does, actually. It works when the spliced-in code comes from another package (although this causes another problem, currently), and we should make it work also for your case where the code comes from the same package. With some improvements to the GHC API (and Haddock), we should be able to fix this. David From eelco at lempsink.nl Mon Dec 15 04:06:35 2008 From: eelco at lempsink.nl (Eelco Lempsink) Date: Mon Dec 15 03:59:23 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <1229308297.6354.14.camel@derek-laptop> References: <20081214211504.GO27904@scytale.galois.com> <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> <1229308297.6354.14.camel@derek-laptop> Message-ID: Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/477b8656/PGP.bin From david.waern at gmail.com Mon Dec 15 04:11:42 2008 From: david.waern at gmail.com (David Waern) Date: Mon Dec 15 04:04:27 2008 Subject: [Haskell-cafe] Problem with haddock 2.3.0 (again) In-Reply-To: <1229037348.10115.580.camel@localhost> References: <1228929679.10115.516.camel@localhost> <3c6288ab0812110229y31b691q6c240e1f505d8992@mail.gmail.com> <1228994548.10115.544.camel@localhost> <3c6288ab0812110726o5f2e1c9ese8a44c702efdec58@mail.gmail.com> <1229014018.10115.568.camel@localhost> <3c6288ab0812110920h7270a548j8ee896a83ee99083@mail.gmail.com> <1229032986.10115.574.camel@localhost> <3c6288ab0812111432r10d0f3a4t4b424e3f0868fa27@mail.gmail.com> <1229037348.10115.580.camel@localhost> Message-ID: 2008/12/12 Duncan Coutts : > Let's see what David thinks. If he thinks is possible to fix these kinds > of things where haddock is not covering the whole GHC AST (at least to > the degree where it can ignore bits it does not understand). If that's > not realistic in the short term then we probably should introduce some > haddock version macro so that people can workaround it. Haddock already tries to filter out declarations that it can't (or shouldn't) handle. I think that works well, although it's possible it can be improved. If we find a case where more filtering is needed, it's an easy fix to make. In this case, we can't filter out the TH declarations (since the code might then not compile), but we can perhaps fix the root-cause in the short-term (I'm not sure about that, but I hope so). So let's wait with the flag until we find something that can't be filtered out and for which we don't have a short-term fix? David From 666wman at gmail.com Mon Dec 15 05:35:24 2008 From: 666wman at gmail.com (wman) Date: Mon Dec 15 05:28:09 2008 Subject: [Haskell-cafe] Re: [Haskell] Re: Help : A problem with IO In-Reply-To: <719881900811271010r313d3becqefa9fa4b772b5666@mail.gmail.com> References: <719881900811260812p207fcbb2y9ad6d1f33a13ed10@mail.gmail.com> <719881900811260818n5899ab93v51b509cd38dba166@mail.gmail.com> <719881900811271010r313d3becqefa9fa4b772b5666@mail.gmail.com> Message-ID: you probably got it pointed out in haskell-beginners, but in case not: On Thu, Nov 27, 2008 at 7:10 PM, abdullah abdul Khadir < abdullah.ak2002@gmail.com> wrote: > a) I need to put a do after else for more than one instruction (?) No, the do thingy is a syntactic sugar for chaining "warm, fuzzy" (the "preffered" wannabe-joke-term for the presumably scary term monads/monadic) operations. it allows you to write in "classical" imperative/sequential style instead of chaining operations manually (using the >> and >>= operators, which the do notation translates into anyway). lookup some monad tutorials/docs. you are right in that if there is only one operation, no transformation is needed, so the do is unnecessary. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/cb2fd47b/attachment.htm From arthurvl at cs.uu.nl Mon Dec 15 05:51:25 2008 From: arthurvl at cs.uu.nl (Arthur van Leeuwen) Date: Mon Dec 15 05:44:24 2008 Subject: [Haskell-cafe] Missing comment highlighting in vim syntax script In-Reply-To: <19CBC89695044E9D98F7CA4C946A789E@cr3lt> References: <4943D057.5090002@avtalion.name> <19CBC89695044E9D98F7CA4C946A789E@cr3lt> Message-ID: <547ED007-85BA-4DFD-9543-74AEA10500BF@cs.uu.nl> On 14 dec 2008, at 19:04, Claus Reinke wrote: >> The Haskell syntax script for vim mentions this mailing list as the >> maintainer. Perhaps one of you could fix this bug. >> Comments on the same line as import declarations don't get >> highlighted: > > I don't know how this list-as-maintainer idea is going to work, > but the fix seems straightforward: find the line in $VIMRUNTIME/ > syntax/haskell.vim that says > > syn match hsImport "\.*"he=s+6 contains=hsImportMod > > and change it to > > syn match hsImport "\.*"he=s+6 > contains=hsImportMod,hsLineComment,hsBlockComment > > See :help syn-contains. Good fix. Have also modified my copy and forwarded the patch to the vim maintainer. With kind regards, Arthur van Leeuwen. -- Arthur van Leeuwen arthurvl@cs.uu.nl From lemming at henning-thielemann.de Mon Dec 15 06:43:29 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Dec 15 06:36:21 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: On Sun, 14 Dec 2008, Don Stewart wrote: > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > Simple, clean and *pure*. > > Instead of the "we got lots going on" of the current logo. Call me conservative, but I like the current logo more than the new suggestions. Why isn't it shown big on the welcome page of haskell.org? From alvivi at gmail.com Mon Dec 15 07:24:42 2008 From: alvivi at gmail.com (=?ISO-8859-1?Q?=C1lvaro?= Vilanova Vidal) Date: Mon Dec 15 07:18:02 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <1229343882.4444.5.camel@localhost.localdomain> One more concept. -------------- next part -------------- A non-text attachment was scrubbed... Name: haskell_infinitylambda_logo.svg Type: image/svg+xml Size: 7817 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/b972401c/haskell_infinitylambda_logo.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: haskell_infinitylambda.svg Type: image/svg+xml Size: 8272 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/b972401c/haskell_infinitylambda.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: haskell_infinitylambda.png Type: image/png Size: 16162 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/b972401c/haskell_infinitylambda.png From tom.davie at gmail.com Mon Dec 15 08:34:07 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Dec 15 08:26:55 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> Message-ID: On 15 Dec 2008, at 12:43, Henning Thielemann wrote: > > On Sun, 14 Dec 2008, Don Stewart wrote: > >> I noticed a new haskell logo idea on a tshirt today, >> >> http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png >> >> Simple, clean and *pure*. >> >> Instead of the "we got lots going on" of the current logo. > > Call me conservative, but I like the current logo more than the new > suggestions. Why isn't it shown big on the welcome page of > haskell.org? Are you referring to this logo? -------------- next part -------------- A non-text attachment was scrubbed... Name: Haskell.png Type: image/png Size: 7174 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/f822cbdd/Haskell.png -------------- next part -------------- In which case, it is shown on Haskell.org, unless there's another logo that I don't know about? Personally, this logo I find cluttered, and complicated, which I suspect conveys something to people thinking about using Haskell. Bob From mblazevic at stilo.com Mon Dec 15 08:48:10 2008 From: mblazevic at stilo.com (Mario Blazevic) Date: Mon Dec 15 08:41:03 2008 Subject: [Haskell-cafe] Multi-parameter type class woes In-Reply-To: <57526e770812142045w255fb42bwb882e435f2fa61eb@mail.gmail.com> References: <.1229314200@magma.ca> <57526e770812142045w255fb42bwb882e435f2fa61eb@mail.gmail.com> Message-ID: <4946601A.6000900@stilo.com> Alexander Dunlap wrote: > On Sun, Dec 14, 2008 at 8:10 PM, Mario Bla?evi? wrote: >>> I'll take a swing at this one: >>> >>> instance Container (Maybe x) [x] where >>> wrapper = isNothing >>> . . . >>> >>> That isn't a sensible definition of 'wrapper', but I believe without >>> trying to compile it is completely legal. Which wrapper do you use? >>> >>> You /don't/ have a different matching Container instance, but without the >>> functional dependency you /might/, and ghc barfs. >> >> But liftWrap doesn't require any particular instance, it's a >> generic function accepting any pair of types for which there is >> an instance of Container. Instance selection (as I understand it) >> shouldn't come into play until one applies liftWrap to a >> particular type, and indeed it does cause problems there: note >> the type annotations on the last line. That part I understand >> and accept, or at least have learned to live with. > > The problem is that y is not mentioned in the signature of wrapper. > When you call wrapper x, there could be many different instances of > Container x y with the same x, so GHC doesn't know which version to > call. I guess I see it now. However, if the explicit 'Container x y =>' context couldn't fix the y to use for instantiation of Container x y, I don't see any way to fix it. And if there is no way to call wrapper in any context, the class declaration itself is illegal and GHC should have reported the error much sooner. Should I create a ticket? > You can fix this problem either by adding a functional > dependency or by splitting wrapper out into its own class (Wrapper x, > e.g.) so all of the type variables in the class head are mentioned in > its type and the instance can be determined by the call. > > Thanks for asking this question, by the way. I had known about this > issue but had never really realized why it happened. Now that I have > thought about it, I understand it too. :) > > Hope that helps, > Alex > From martindemello at gmail.com Mon Dec 15 08:50:27 2008 From: martindemello at gmail.com (Martin DeMello) Date: Mon Dec 15 08:43:12 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> Message-ID: Something incorporating ?? perhaps martin From marlowsd at gmail.com Mon Dec 15 09:00:37 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Dec 15 08:53:25 2008 Subject: [Haskell-cafe] Re: Threads not running under GHC 6.10? In-Reply-To: References: Message-ID: <49466305.4050009@gmail.com> Gwern Branwen wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > So, the Hint library was recently updated and I was editing Mueval to > run with (i386) 6.10, when I discovered that for some reason, DoS'ing > expressions were succeeding in rendering my machine unusable. > Eventually, I discovered that my watchdog thread didn't seem to be > running. But with +RTS -N2 -RTS all my tests did pass! > > Here's a simple example of what I mean; the following is basically a > very lightly adapted version of the actual Mueval code: > > - ---------------- > import Control.Concurrent (forkIO, killThread, myThreadId, > threadDelay, throwTo, yield, ThreadId) > import System.Posix.Signals (sigXCPU, installHandler, Handler(CatchOnce)) > import Control.OldException (Exception(ErrorCall)) > > main :: IO () > main = do tid ThreadId -> IO () > watchDog tout tid = do installHandler sigXCPU > (CatchOnce > $ throwTo tid $ ErrorCall > "Time limit exceeded.") Nothing > forkIO $ do threadDelay (tout * 100000) > -- Time's up. It's a good day to die. > throwTo tid (ErrorCall "Time limit exceeded") > yield -- give the other thread a chance > killThread tid -- Die now, srsly. > error "Time expired" > return () -- Never reached. Either we error out in > -- watchDog, or the evaluation thread finishes. This particular example illustrates a bug in 6.10.1 that we've since fixed: http://hackage.haskell.org/trac/ghc/ticket/2783 However in general you can still write expressions that don't allocate anything (e.g. nfib 1000), and your watchdog thread won't get a chance to run unless there's a spare CPU available (+RTS -N2). Cheers, Simon From thomas.dubuisson at gmail.com Mon Dec 15 09:15:21 2008 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Mon Dec 15 09:09:12 2008 Subject: [Haskell-cafe] Multi-parameter type class woes In-Reply-To: <4946601A.6000900@stilo.com> References: <.1229314200@magma.ca> <57526e770812142045w255fb42bwb882e435f2fa61eb@mail.gmail.com> <4946601A.6000900@stilo.com> Message-ID: <4c44d90b0812150615v200aa603pf9d73667bc4f4a81@mail.gmail.com> 2008/12/15 Mario Blazevic > Alexander Dunlap wrote: > >> The problem is that y is not mentioned in the signature of wrapper. >> When you call wrapper x, there could be many different instances of >> Container x y with the same x, so GHC doesn't know which version to >> call. >> > > > I guess I see it now. However, if the explicit 'Container x y =>' > context couldn't fix the y to use for instantiation of Container x y, I > don't see any way to fix it. And if there is no way to call wrapper in any > context, the class declaration itself is illegal and GHC should have > reported the error much sooner. Should I create a ticket? > Please do not create a ticket. Such a typeclass is legitimate, but not useful alone or with functional dependencies. It is useful with Type Families though, so celebrate! Thomas ----- START CODE ---- {-# LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleInstances #-} import Data.Maybe class Container x where type Contains x wrapper :: x -> Bool unwrap :: x -> Contains x rewrap :: Contains x -> x liftWrap :: Container x => (Contains x -> Contains x) -> x -> x liftWrap f x = (if wrapper x then rewrap . f . unwrap else id) x instance Container (Maybe x) where type Contains (Maybe x) = x wrapper = isJust unwrap = fromJust rewrap = Just main = print (liftWrap (succ :: Int -> Int) (Just 1 :: Maybe Int)) ----- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/1a5d4554/attachment.htm From thomas.dubuisson at gmail.com Mon Dec 15 09:21:12 2008 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Mon Dec 15 09:14:47 2008 Subject: [Haskell-cafe] Multi-parameter type class woes In-Reply-To: <4c44d90b0812150615v200aa603pf9d73667bc4f4a81@mail.gmail.com> References: <.1229314200@magma.ca> <57526e770812142045w255fb42bwb882e435f2fa61eb@mail.gmail.com> <4946601A.6000900@stilo.com> <4c44d90b0812150615v200aa603pf9d73667bc4f4a81@mail.gmail.com> Message-ID: <4c44d90b0812150621q4a1527d8m39f7fd0315b31a9d@mail.gmail.com> On Mon, Dec 15, 2008 at 2:15 PM, Thomas DuBuisson < thomas.dubuisson@gmail.com> wrote: > 2008/12/15 Mario Blazevic > >> Alexander Dunlap wrote: >> >>> The problem is that y is not mentioned in the signature of wrapper. >>> When you call wrapper x, there could be many different instances of >>> Container x y with the same x, so GHC doesn't know which version to >>> call. >>> >> >> >> I guess I see it now. However, if the explicit 'Container x y =>' >> context couldn't fix the y to use for instantiation of Container x y, I >> don't see any way to fix it. And if there is no way to call wrapper in any >> context, the class declaration itself is illegal and GHC should have >> reported the error much sooner. Should I create a ticket? >> > > > Please do not create a ticket. Such a typeclass is legitimate, but not > useful alone or with functional dependencies. It is useful with Type > Families though, so celebrate! > > Thomas > Ok, now I get to laugh at myself. Caught up in the type family fun, I didn't even notice I obliterated the MPTC issue that started the whole discussion. Slowing down to think, I can't find an example where the original MPTC is any good and it should thus receive a compile time error. Perhaps someone will come along and give a legitimate example. Thomas -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/7d39723d/attachment.htm From jefferson.r.heard at gmail.com Mon Dec 15 10:06:29 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon Dec 15 09:59:17 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <4165d3a70812150706m757d3540rb09907d16ee0fe8b@mail.gmail.com> My entry... 2008/12/15 Martin DeMello : > Something incorporating ?? perhaps > > martin > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: Haskell.pdf Type: application/pdf Size: 145415 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/79da248b/Haskell-0001.pdf -------------- next part -------------- A non-text attachment was scrubbed... Name: Haskell.png Type: image/png Size: 3645 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/79da248b/Haskell-0001.png From gianfranco.alongi at gmail.com Mon Dec 15 10:09:38 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Mon Dec 15 10:04:12 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <4165d3a70812150706m757d3540rb09907d16ee0fe8b@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <4165d3a70812150706m757d3540rb09907d16ee0fe8b@mail.gmail.com> Message-ID: Looks, good, actually among the top of the ones I like, should we not have some kind of voting mechanism for selecting a logo? And also some kind of last date for when entries are accepted.. Of course this requires a call for logos and so forth. 2008/12/15 Jeff Heard : > My entry... > > 2008/12/15 Martin DeMello : >> Something incorporating ?? perhaps >> >> martin >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Patience is the last resort for those unable to take action From nominolo at googlemail.com Mon Dec 15 10:38:11 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Mon Dec 15 10:30:56 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <916b84820812150738w2476a3f0g539ec462d25b08c1@mail.gmail.com> So far this one is still the best, although the kerning between the s and the k seems off, so that would need fixing first. In terms of slogan "purely functional", "lazy with class", or "lazy. pure. functional." look ok. The rest, not so much. 2008/12/14 Don Stewart : > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > Simple, clean and *pure*. > > Instead of the "we got lots going on" of the current logo. > > Any graphic designers want to try some variations on this theme of > purity? > > A new year, and a new mature logo... > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Push the envelope. Watch it bend. From dons at galois.com Mon Dec 15 12:03:44 2008 From: dons at galois.com (Don Stewart) Date: Mon Dec 15 11:56:27 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <916b84820812150738w2476a3f0g539ec462d25b08c1@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <916b84820812150738w2476a3f0g539ec462d25b08c1@mail.gmail.com> Message-ID: <20081215170344.GD30616@scytale.galois.com> And anyone who does a version, place put it on the wiki. It'll be lost if you only post to the list. I propose we gather submissions and vote on the best for a new logo in 2009. -- Don nominolo: > So far this one is still the best, although the kerning between the s > and the k seems off, so that would need fixing first. > > In terms of slogan "purely functional", "lazy with class", or "lazy. > pure. functional." look ok. The rest, not so much. > > 2008/12/14 Don Stewart : > > I noticed a new haskell logo idea on a tshirt today, > > > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > > > Simple, clean and *pure*. > > > > Instead of the "we got lots going on" of the current logo. > > > > Any graphic designers want to try some variations on this theme of > > purity? > > > > A new year, and a new mature logo... > > > > -- Don > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Push the envelope. Watch it bend. From lemming at henning-thielemann.de Mon Dec 15 12:30:31 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Dec 15 12:23:22 2008 Subject: [Haskell-cafe] Time for a new logo? -> Haskell logo as a stamp! In-Reply-To: <20081215170344.GD30616@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> <916b84820812150738w2476a3f0g539ec462d25b08c1@mail.gmail.com> <20081215170344.GD30616@scytale.galois.com> Message-ID: On Mon, 15 Dec 2008, Don Stewart wrote: > And anyone who does a version, place put it on the wiki. > It'll be lost if you only post to the list. > > I propose we gather submissions and vote on the best for a new logo in > 2009. Whatever logo someone prefers: I have written a program using HPDF which creates stamps for the German post (see http://www.internetmarke.de/) with custom images: http://code.haskell.org/~thielema/internetmarke/ It needs a bit generalization, though, and will then be uploaded to Hackage, of course. So a dedicated Haskell stamp is close to German Haskell users! From icfp.publicity at googlemail.com Mon Dec 15 12:51:27 2008 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Mon Dec 15 12:44:16 2008 Subject: [Haskell-cafe] ICFP09 Call for Papers Message-ID: <53ff55480812150951r69578128l2acb88d0bccf8232@mail.gmail.com> Call for Papers ICFP 2009: International Conference on Functional Programming Edinburgh, Scotland, 31 August - 2 September 2009 http://www.cs.nott.ac.uk/~gmh/icfp09.html ** Submission deadline: 2 March 2009 ** (submission deadline is earlier than usual) ICFP 2009 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages, as well as languages with objects or concurrency. Particular topics of interest include * Language Design: type systems; concurrency and distribution; modules; components and composition; metaprogramming; relations to object-oriented or logic programming; interoperability * Implementation: abstract machines; compilation; compile-time and run-time optimization; memory management; multi-threading; exploiting parallel hardware; interfaces to foreign functions, services, components or low-level machine resources * Software-Development Techniques: algorithms and data structures; design patterns; specification; verification; validation; proof assistants; debugging; testing; tracing; profiling * Foundations: formal semantics; lambda calculus; rewriting; type theory; monads; continuations; control; state; effects * Transformation and Analysis: abstract interpretation; partial evaluation; program transformation; program calculation; program proof * Applications and Domain-Specific Languages: symbolic computing; formal-methods tools; artificial intelligence; systems programming; distributed-systems and web programming; hardware design; databases; XML processing; scientific and numerical computing; graphical user interfaces; multimedia programming; scripting; system administration; security; education * Functional Pearls: elegant, instructive, and fun essays on functional programming The conference also solicits Experience Reports, which are short papers that provide evidence that functional programming really works or describe obstacles that have kept it from working in a particular application. What's different this year? ~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The conference dates and the submission deadline are about one month earlier than usual. * Special 'Call for Experience Reports' page, suitable as a target for posts on blogs and social networks to reach practitioners who wouldn't normally think about submitting to a conference. If you have a blog, etc., please help by pointing your readers to: http://web.cecs.pdx.edu/~apt/icfp09_cfer.html Instructions for authors ~~~~~~~~~~~~~~~~~~~~~~~~ By Monday, 2 March 2009, 20:00 UTC, submit an abstract of at most 300 words and a full paper of at most 12 pages (4 pages for an Experience Report), including bibliography and figures. The deadline will be strictly enforced and papers exceeding the page limits will be summarily rejected. Authors have the option to attach supplementary material to a submission, on the understanding that reviewers may choose not to look at it. A submission will be evaluated according to its relevance, correctness, significance, originality, and clarity. It should explain its contributions in both general and technical terms, clearly identifying what has been accomplished, explaining why it is significant, and comparing it with previous work. The technical content should be accessible to a broad audience. Functional Pearls and Experience Reports are separate categories of papers that need not report original research results and must be marked as such at the time of submission. Detailed guidelines on both categories are below. Each submission must adhere to SIGPLAN's republication policy, as explained on the web. Violation risks summary rejection of the offending submission. Proceedings will be published by ACM Press. Authors of accepted submissions are expected to transfer the copyright to ACM. Presentations will be videotaped and released online if the presenter consents by signing an additional permission form at the time of the presentation. Released videos will be included along with the conference proceedings in the ACM Digital Library and may also be placed on a host such as YouTube or Google Video. Formatting: ~~~~~~~~~~~ Submissions must be in PDF format printable in black and white on US Letter sized paper and interpretable by Ghostscript. If this requirement is a hardship, make contact with the program chair at least one week before the deadline. ICFP proceedings are printed in black and white. It is permissible to include color in a submission, but you risk annoying reviewers who will have to decide if your final paper will be understandable without it. Papers must adhere to the standard ACM conference format: two columns, nine-point font on a ten-point baseline, with columns 20pc (3.33in) wide and 54pc (9in) tall, with a column gutter of 2pc (0.33in). A suitable document template for LaTeX is available from SIGPLAN. Submission: ~~~~~~~~~~~ Submissions will be accepted electronically at a URL to be named later. The deadline is set in Coordinated Universal Time. The world clock (http://www.timeanddate.com/worldclock/fixedtime.html?month=3&day=2&year=2009&hour=20&min=0&sec=0&p1=0) can give you the equivalent in your local time, e.g., Noon Monday in Seattle, 3:00 PM Monday in New York, 8:00 PM Monday in London, 5:00 AM Tuesday in Tokyo. Citation: ~~~~~~~~~ We recommend (but do not require) that you put your citations into author-date form. This procedure makes your paper easier to review. For example, if you cite a result on testing as ``(Claessen and Hughes 2000)'', many reviewers will recognize the result instantly. On the other hand, if you cite it as ``[4]'', even the best-informed reviewer has to page through your paper to find the reference. By using author-date form, you enable a knowledgeable reviewer to focus on content, not arbitrary numbering of references. LaTeX users can simply use the natbib package along with the plainnat bibliography style. In practice, this means putting \usepackage{natbib} \bibpunct();A{}, \let\cite=\citep in your LaTeX preamble, and \bibliographystyle{plainnat} in your document. For most citations you will use the \cite command; if you want a citation like ``Claessen and Hughes (2000) showed that...'' you should use something like ``\citet{claessen:quickcheck} showed...'' Alternatively, the McBride bibliography style, which adheres to the Chicago manual of style ``Documentation Two'' specifications and which fixes some perceived deficiencies of natbib, may be used. The style file along with instructions for using it is available on the McBride web site. Author response: ~~~~~~~~~~~~~~~~ Authors will have a 48-hour period, starting at 20:00 UTC on 21 April 2009, to read and respond to reviews. Special categories of papers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In addition to research papers, ICFP solicits two kinds of papers that do not require original research contributions: Functional Pearls, which are full papers, and Experience Reports, which are limited to four pages. Authors submitting such papers may wish to consider the following advice. Functional Pearls ~~~~~~~~~~~~~~~~~ A Functional Pearl is an elegant essay about something related to functional programming. It might offer: * a new and thought-provoking way of looking at an old idea * an instructive example of program calculation or proof * a nifty presentation of an old or new data structure * an interesting application of functional programming techniques * a novel use or exposition of functional programming in the classroom Functional Pearls are not restricted to the above varieties, however. While pearls often demonstrate an idea through the development of a short program, there is no requirement or expectation that they do so. Thus, they encompass the notions of theoretical and educational pearls. Functional Pearls are valued as highly and judged as rigorously as ordinary papers, but using somewhat different criteria. In particular, a pearl is not required to report original research. However, it should be concise, instructive, and entertaining. Your pearl is likely to be rejected if your readers get bored, if the material gets too complicated, if too much specialized knowledge is needed, or if the writing is inelegant. The key to writing a good pearl is polishing. A submission you wish to have treated as a pearl must be marked as such on the submission web page, and should contain the words ``Functional Pearl'' somewhere in its title or subtitle. These steps will alert reviewers to use the appropriate evaluation criteria. However, pearls will be combined with ordinary papers for the purpose of computing the conference's acceptance rate. Experience Reports ~~~~~~~~~~~~~~~~~~ The purpose of an Experience Report is to help create a body of published, refereed, citable evidence that functional programming really works---or to describe what obstacles prevent it from working. Possible topics for an Experience Report include, but are not limited to: * insights gained from real-world projects using functional programming * comparison of functional programming with conventional programming in the context of an industrial project or a university curriculum * project-management, business, or legal issues encountered when using functional programming in a real-world project * curricular issues encountered when using functional programming in education * real-world constraints that created special challenges for an implementation of a functional language or for functional programming in general An Experience Report is distinguished from a normal ICFP paper by its title, by its length, and by the criteria used to evaluate it. * Both in the proceedings and in any citations, the title of each accepted Experience Report must begin with the words ``Experience Report'' followed by a colon. The acceptance rate for Experience Reports will be computed and reported separately from the rate for ordinary papers. * An Experience Report is at most 4 pages long. Each accepted Experience Report will be presented at the conference, but depending on the number of Experience Reports and regular papers accepted, authors of Experience reports may be asked to give shorter talks. * Because the purpose of Experience Reports is to enable our community to accumulate a body of evidence about the efficacy of functional programming, an acceptable Experience Report need not add to the body of knowledge of the functional-programming community by presenting novel results or conclusions. It is sufficient if the Report states a clear thesis and provides supporting evidence. The thesis must be relevant to ICFP, but it need not be novel. The program committee will accept or reject Experience Reports based on whether they judge the evidence to be convincing. Anecdotal evidence will be acceptable provided it is well argued and the author explains what efforts were made to gather as much evidence as possible. Typically, more convincing evidence is obtained from papers which show how functional programming was used than from papers which only say that functional programming was used. The most convincing evidence often includes comparisons of situations before and after the introduction or discontinuation of functional programming. Evidence drawn from a single person's experience may be sufficient, but more weight will be given to evidence drawn from the experience of groups of people. An Experience Report should be short and to the point: make a claim about how well functional programming worked on your project and why, and produce evidence to substantiate your claim. If functional programming worked for you in the same ways it has worked for others, you need only to summarize the results---the main part of your paper should discuss how well it worked and in what context. Most readers will not want to know all the details of your project and its implementation, but please characterize your project and its context well enough so that readers can judge to what degree your experience is relevant to their own projects. Be especially careful to highlight any unusual aspects of your project. Also keep in mind that specifics about your project are more valuable than generalities about functional programming; for example, it is more valuable to say that your team delivered its software a month ahead of schedule than it is to say that functional programming made your team more productive. If your paper not only describes experience but also presents new technical results, or if your experience refutes cherished beliefs of the functional-programming community, you may be better off submitting it as a full paper, which will be judged by the usual criteria of novelty, originality, and relevance. If you are unsure in which category to submit, the program chair will be happy to help you decide. Other information ~~~~~~~~~~~~~~~~~ Conference Chair ~~~~~~~~~~~~~~~~ Graham Hutton (University of Nottingham) Program Chair ~~~~~~~~~~~~~ Andrew Tolmach Department of Computer Science Portland State University P.O. Box 751, Portland, OR 97207 USA Email: apt@cs.pdx.edu Phone: +1 503 725 5492 Fax: +1 503 725 3211 Mail sent to the address above is filtered for spam. If you send mail and do not receive a prompt response, particularly if the deadline is looming, feel free to telephone. Program Committee ~~~~~~~~~~~~~~~~~ Amal Ahmed (Toyota Technological Institute, Chicago) Maria Alpuente (Technical University of Valencia (UPV)) Lennart Augustsson (Standard Chartered Bank) Lars Birkedal (IT University of Copenhagen) Manuel Chakravarty (University of New South Wales) Koen Claessen (Chalmers University of Technology) Marc Feeley (Universite de Montreal) Andrzej Filinski (University of Copenhagen) Daan Leijen (Microsoft Research) Xavier Leroy (INRIA Paris-Rocquencourt) Conor McBride (University of Strathclyde) Matthew Might (University of Utah) Shin-Cheng Mu (Academia Sinica) Atsushi Ohori (Tohoku University) Kristoffer Rose (IBM Thomas J. Watson Research Center) Important Dates (at 20:00 UTC) ~~~~~~~~~~~~~~~ Submission: 2 March 2009 Author response: 21-23 April 2009 Notification: 5 May 2009 Final papers due: 8 June 2009 ICFP 2009 Web Site ~~~~~~~~~~~~~~~~~~ http://www.cs.nott.ac.uk/~gmh/icfp09.html Special Journal Issue ~~~~~~~~~~~~~~~~~~~~~ There will be a special issue of the Journal of Functional Programming with papers from ICFP 2009. The program committee will invite the authors of select accepted papers to submit a journal version to this issue. From Brettschneider at hs-albsig.de Mon Dec 15 14:07:49 2008 From: Brettschneider at hs-albsig.de (Brettschneider, Matthias) Date: Mon Dec 15 14:00:34 2008 Subject: [Haskell-cafe] Time for a new logo? Message-ID: <46E28C090A923641BFCC8D6C9CCD10B95DDF82C247@izcexchange.ad.fh-albsig.de> If there is someone interested in playing around with the logo Don posted, I made a gimp-version out of it. http://frosch03.de/haskell/Haskell.xcf http://frosch03.de/haskell/Haskell.png -- Matthias From dons at galois.com Mon Dec 15 14:36:08 2008 From: dons at galois.com (Don Stewart) Date: Mon Dec 15 14:28:42 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <4165d3a70812150706m757d3540rb09907d16ee0fe8b@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <4165d3a70812150706m757d3540rb09907d16ee0fe8b@mail.gmail.com> Message-ID: <20081215193608.GB31082@scytale.galois.com> Could you upload it to the logo contest page: http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas jefferson.r.heard: > My entry... > > 2008/12/15 Martin DeMello : > > Something incorporating ?? perhaps > > > > martin > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lgreg.meredith at biosimilarity.com Mon Dec 15 15:23:08 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Mon Dec 15 15:15:55 2008 Subject: [Haskell-cafe] haskell compiler never comes back Message-ID: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> Haskellians, The simple-minded and smallish code sample at this linkcauses the compiler to go off into never-never land. Any clues would be greatly appreciated. Best wishes, --greg -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/e26719da/attachment.htm From porges at porg.es Mon Dec 15 16:34:53 2008 From: porges at porg.es (George Pollard) Date: Mon Dec 15 16:27:49 2008 Subject: [Haskell-cafe] Data.List.Split In-Reply-To: <404396ef0812150040v5c9dc796ge79d3265ae949bbc@mail.gmail.com> References: <20081213163036.GA8353@seas.upenn.edu> <20081213164755.GA9663@seas.upenn.edu> <20081214053502.GA12106@nixos.uwaterloo.ca> <1229237218.7077.3.camel@porges-laptop> <1229237472.7077.5.camel@porges-laptop> <404396ef0812150040v5c9dc796ge79d3265ae949bbc@mail.gmail.com> Message-ID: <1229376893.6628.2.camel@porges-laptop> On Mon, 2008-12-15 at 08:40 +0000, Neil Mitchell wrote: > That can only be a bug in stream fusion - concatMap should always be prefered! Yes, but it is unclear from the article whether the concatMap (w/ stream fusion enabled) is Data.List.Stream's concatMap or the Prelude's concatMap. It's only a bug in the former case :) - George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/ceaa4b4d/attachment.bin From andrewcoppin at btinternet.com Mon Dec 15 17:15:11 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Dec 15 17:07:51 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <4946D6EF.7040106@btinternet.com> Don Stewart wrote: > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > Simple, clean and *pure*. > > Instead of the "we got lots going on" of the current logo. > > Any graphic designers want to try some variations on this theme of > purity? > > A new year, and a new mature logo... > Well overdue, IMHO. I showed the current logo to Mr C++ (who, obviously, is slightly biased). To him, apparently, the current logo says "Haskell is all about arcane and obscure mathematical constructs. In fact, we think that complicated mathematics is so good that we stuffed our logo full of it. If you don't like hard math, don't even bother trying to learn this language." Obviously, that's a rather negative image to be projecting. And obviously, his opinion is biased. To me, the logo just looks a) rather cluttered, and b) home-made. It doesn't have that professional "glitter" to it. (I have no idea how to fix that though - maybe ask a professional??) I see lots of people posting various logos, but they all seem to consist essentially of a lambda and the word "Haskell". I guess it depends on what you want from a logo. Is our "logo" going to be just a lambda symbol in a specific typeface with specific colours? Or do we want something more particular? (Looking at what other languages have... well "Ruby" has a gemstone. Duh. And "Python" has two snakes nicely stylised. Oh well!) But yeah, certainly I think having a neat T-shirt to wear would be fun! (Note that the lambda was the symbol for the LGBT folks though!) (Actually, just noticing... Ruby's front page says "Hello World is trivial - here it is!" We can do that too, eh?) From lgreg.meredith at biosimilarity.com Mon Dec 15 17:16:23 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Mon Dec 15 17:09:05 2008 Subject: [Haskell-cafe] Re: haskell compiler never comes back In-Reply-To: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> Message-ID: <5de3f5ca0812151416v20a67a3x59cb8a7abfb07a99@mail.gmail.com> Haskellians, An even simpler version that reveals the issue. i'm astounded that the compiler literally just hangs. Best wishes, --greg On Mon, Dec 15, 2008 at 12:23 PM, Greg Meredith < lgreg.meredith@biosimilarity.com> wrote: > Haskellians, > > The simple-minded and smallish code sample at this linkcauses the compiler to go off into never-never land. Any clues would be > greatly appreciated. > > Best wishes, > > --greg > > -- > L.G. Meredith > Managing Partner > Biosimilarity LLC > 806 55th St NE > Seattle, WA 98105 > > +1 206.650.3740 > > http://biosimilarity.blogspot.com > -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/4f990c5c/attachment.htm From lgreg.meredith at biosimilarity.com Mon Dec 15 17:40:17 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Mon Dec 15 17:33:00 2008 Subject: [Haskell-cafe] Re: haskell compiler never comes back In-Reply-To: <1229380447.11139.5.camel@porges-laptop> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> <5de3f5ca0812151416v20a67a3x59cb8a7abfb07a99@mail.gmail.com> <1229380447.11139.5.camel@porges-laptop> Message-ID: <5de3f5ca0812151440x432fbf83vc2ad5494e4174db@mail.gmail.com> George, Thanks for the response. If i take out the AllowUndecidableInstances i get no complaints and the compiler hangs. See this. Thus, i can find no observable difference for this flag in this particular code sample. Best wishes, --greg On Mon, Dec 15, 2008 at 2:34 PM, George Pollard wrote: > This is precisely what AllowUndecidableInstances allows; the type > checking becomes possibly non-terminating. It should *eventually* > terminate because the stack depth is restricted. > > - George > -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/f624188e/attachment.htm From daniel.is.fischer at web.de Mon Dec 15 17:50:11 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Dec 15 17:40:28 2008 Subject: [Haskell-cafe] Re: haskell compiler never comes back In-Reply-To: <5de3f5ca0812151416v20a67a3x59cb8a7abfb07a99@mail.gmail.com> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> <5de3f5ca0812151416v20a67a3x59cb8a7abfb07a99@mail.gmail.com> Message-ID: <200812152350.11554.daniel.is.fischer@web.de> Am Montag, 15. Dezember 2008 23:16 schrieb Greg Meredith: > Haskellians, > > An even simpler version that reveals > the issue. i'm astounded that the compiler literally just hangs. > > Best wishes, > > --greg > > On Mon, Dec 15, 2008 at 12:23 PM, Greg Meredith < > > lgreg.meredith@biosimilarity.com> wrote: > > Haskellians, > > > > The simple-minded and smallish code sample at this > > linkcauses the compiler to go off > > into never-never land. Any clues would be greatly appreciated. > > > > Best wishes, > > > > --greg I can't confirm it, with 6.8.3: $ ghc -O2 --make Monoidal.hs [1 of 1] Compiling Monoidal ( Monoidal.hs, Monoidal.o ) Monoidal.hs:110:11: Couldn't match expected type `i1' against inferred type `Isomorpism (HFTensorExpr a i) a' `i1' is a rigid type variable bound by the instance declaration at Monoidal.hs:103:42 In the expression: (PutIn (\ a -> (HFTLVal a))) In the third argument of `HFTExpr', namely `[(PutIn (\ a -> (HFTLVal a)))]' In the expression: (HFTExpr (HFTLVal a) (HFTRVal b) [(PutIn (\ a -> (HFTLVal a)))] [(PutIn (\ b -> (HFTRVal b)))]) $ and the earlier version: $ ghc -O2 --make Monoidal2.hs [1 of 1] Compiling Monoidal2 ( Monoidal2.hs, Monoidal2.o ) Monoidal2.hs:105:18: Couldn't match expected type `HFTensorExpr a i' against inferred type `[i1] -> [i1] -> HFTensorExpr a i1' In the expression: HFTExpr (HFTLVal a) (HFTRVal b) In the definition of `tMult': a tMult b = HFTExpr (HFTLVal a) (HFTRVal b) In the definition for method `tMult' Monoidal2.hs:122:10: Couldn't match expected type `[]' against inferred type `++ msa' Expected type: [i] Inferred type: ++ msa msb In the third argument of `HFTExpr', namely `((Shuffle (\ (HFTExpr (HFTExpr u v msu msv) w msuv msw) -> (tAssoc (HFTExpr (HFTExpr u v msu msv) w msuv msw)))) :: msa ++ msb)' In the expression: (HFTExpr (HFTExpr a b msa msb) c ((Shuffle (\ (HFTExpr (HFTExpr u v msu msv) w msuv msw) -> (tAssoc (HFTExpr (HFTExpr u v msu msv) w msuv msw)))) :: msa ++ msb) msc) Monoidal2.hs:139:10: Couldn't match expected type `[]' against inferred type `++ msl' Expected type: [i] Inferred type: ++ msl msr In the third argument of `HFTExpr', namely `((Shuffle (\ (HFTExpr (HFTExpr a b msa msb) c msab msc) -> (tAssoc (HFTExpr (HFTExpr a b msa msb) c msab msc)))) :: msl ++ msr)' In the expression: (HFTExpr (HFTExpr l r msl msr) (HFTRVal b) ((Shuffle (\ (HFTExpr (HFTExpr a b msa msb) c msab msc) -> (tAssoc (HFTExpr (HFTExpr a b msa msb) c msab msc)))) :: msl ++ msr) [(PutIn (\ b -> (HFTRVal b)))]) Monoidal2.hs:150:11: Couldn't match expected type `i1' against inferred type `Isomorpism (HFTensorExpr a i) a' `i1' is a rigid type variable bound by the instance declaration at Monoidal2.hs:103:42 In the expression: (PutIn (\ a -> (HFTRVal a))) In the third argument of `HFTExpr', namely `[(PutIn (\ a -> (HFTRVal a)))]' In the expression: (HFTExpr (HFTLVal a) (HFTRVal b) [(PutIn (\ a -> (HFTRVal a)))] [(PutIn (\ b -> (HFTRVal b)))]) $ No hang, which compiler version did you use? From lgreg.meredith at biosimilarity.com Mon Dec 15 17:49:55 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Mon Dec 15 17:42:39 2008 Subject: [Haskell-cafe] Re: haskell compiler never comes back In-Reply-To: <200812152350.11554.daniel.is.fischer@web.de> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> <5de3f5ca0812151416v20a67a3x59cb8a7abfb07a99@mail.gmail.com> <200812152350.11554.daniel.is.fischer@web.de> Message-ID: <5de3f5ca0812151449l30a42dc2q86887a1d84f04bba@mail.gmail.com> Daniel, Thanks. i'm using GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :l monoidal.hs [1 of 1] Compiling Monoidal ( monoidal.hs, interpreted ) C-c C-cInterrupted. > :q Best wishes, --greg On Mon, Dec 15, 2008 at 2:50 PM, Daniel Fischer wrote: > Am Montag, 15. Dezember 2008 23:16 schrieb Greg Meredith: > > Haskellians, > > > > An even simpler version that > reveals > > the issue. i'm astounded that the compiler literally just hangs. > > > > Best wishes, > > > > --greg > > > > On Mon, Dec 15, 2008 at 12:23 PM, Greg Meredith < > > > > lgreg.meredith@biosimilarity.com> wrote: > > > Haskellians, > > > > > > The simple-minded and smallish code sample at this > > > linkcauses the compiler to go off > > > into never-never land. Any clues would be greatly appreciated. > > > > > > Best wishes, > > > > > > --greg > > I can't confirm it, with 6.8.3: > > $ ghc -O2 --make Monoidal.hs > [1 of 1] Compiling Monoidal ( Monoidal.hs, Monoidal.o ) > > Monoidal.hs:110:11: > Couldn't match expected type `i1' > against inferred type `Isomorpism (HFTensorExpr a i) a' > `i1' is a rigid type variable bound by > the instance declaration at Monoidal.hs:103:42 > In the expression: (PutIn (\ a -> (HFTLVal a))) > In the third argument of `HFTExpr', namely > `[(PutIn (\ a -> (HFTLVal a)))]' > In the expression: > (HFTExpr > (HFTLVal a) > (HFTRVal b) > [(PutIn (\ a -> (HFTLVal a)))] > [(PutIn (\ b -> (HFTRVal b)))]) > $ > > and the earlier version: > > $ ghc -O2 --make Monoidal2.hs > [1 of 1] Compiling Monoidal2 ( Monoidal2.hs, Monoidal2.o ) > > Monoidal2.hs:105:18: > Couldn't match expected type `HFTensorExpr a i' > against inferred type `[i1] -> [i1] -> HFTensorExpr a i1' > In the expression: HFTExpr (HFTLVal a) (HFTRVal b) > In the definition of `tMult': > a tMult b = HFTExpr (HFTLVal a) (HFTRVal b) > In the definition for method `tMult' > > Monoidal2.hs:122:10: > Couldn't match expected type `[]' against inferred type `++ msa' > Expected type: [i] > Inferred type: ++ msa msb > In the third argument of `HFTExpr', namely > `((Shuffle > (\ (HFTExpr (HFTExpr u v msu msv) w msuv msw) > -> (tAssoc (HFTExpr (HFTExpr u v msu msv) w msuv msw)))) > :: > msa ++ msb)' > In the expression: > (HFTExpr > (HFTExpr a b msa msb) > c > ((Shuffle > (\ (HFTExpr (HFTExpr u v msu msv) w msuv msw) > -> (tAssoc (HFTExpr (HFTExpr u v msu msv) w msuv msw)))) > :: > msa ++ msb) > msc) > > Monoidal2.hs:139:10: > Couldn't match expected type `[]' against inferred type `++ msl' > Expected type: [i] > Inferred type: ++ msl msr > In the third argument of `HFTExpr', namely > `((Shuffle > (\ (HFTExpr (HFTExpr a b msa msb) c msab msc) > -> (tAssoc (HFTExpr (HFTExpr a b msa msb) c msab msc)))) > :: > msl ++ msr)' > In the expression: > (HFTExpr > (HFTExpr l r msl msr) > (HFTRVal b) > ((Shuffle > (\ (HFTExpr (HFTExpr a b msa msb) c msab msc) > -> (tAssoc (HFTExpr (HFTExpr a b msa msb) c msab msc)))) > :: > msl ++ msr) > [(PutIn (\ b -> (HFTRVal b)))]) > > Monoidal2.hs:150:11: > Couldn't match expected type `i1' > against inferred type `Isomorpism (HFTensorExpr a i) a' > `i1' is a rigid type variable bound by > the instance declaration at Monoidal2.hs:103:42 > In the expression: (PutIn (\ a -> (HFTRVal a))) > In the third argument of `HFTExpr', namely > `[(PutIn (\ a -> (HFTRVal a)))]' > In the expression: > (HFTExpr > (HFTLVal a) > (HFTRVal b) > [(PutIn (\ a -> (HFTRVal a)))] > [(PutIn (\ b -> (HFTRVal b)))]) > $ > > No hang, which compiler version did you use? > -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/07fa512a/attachment.htm From lgreg.meredith at biosimilarity.com Mon Dec 15 17:52:50 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Mon Dec 15 17:45:33 2008 Subject: [Haskell-cafe] Re: haskell compiler never comes back In-Reply-To: <5de3f5ca0812151449l30a42dc2q86887a1d84f04bba@mail.gmail.com> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> <5de3f5ca0812151416v20a67a3x59cb8a7abfb07a99@mail.gmail.com> <200812152350.11554.daniel.is.fischer@web.de> <5de3f5ca0812151449l30a42dc2q86887a1d84f04bba@mail.gmail.com> Message-ID: <5de3f5ca0812151452n6b67d136h7c2259b2a4172d43@mail.gmail.com> Daniel, BTW, if i comment out the version of PutIn that calls HF{L,R}Val and put in the unit, instead, i see the complaint you're seeing. i'll upgrade ghc. Best wishes, --greg On Mon, Dec 15, 2008 at 2:49 PM, Greg Meredith < lgreg.meredith@biosimilarity.com> wrote: > Daniel, > > Thanks. i'm using > > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > Prelude> :l monoidal.hs > [1 of 1] Compiling Monoidal ( monoidal.hs, interpreted ) > C-c C-cInterrupted. > > :q > > Best wishes, > > --greg > > > On Mon, Dec 15, 2008 at 2:50 PM, Daniel Fischer wrote: > >> Am Montag, 15. Dezember 2008 23:16 schrieb Greg Meredith: >> > Haskellians, >> > >> > An even simpler version that >> reveals >> > the issue. i'm astounded that the compiler literally just hangs. >> > >> > Best wishes, >> > >> > --greg >> > >> > On Mon, Dec 15, 2008 at 12:23 PM, Greg Meredith < >> > >> > lgreg.meredith@biosimilarity.com> wrote: >> > > Haskellians, >> > > >> > > The simple-minded and smallish code sample at this >> > > linkcauses the compiler to go off >> > > into never-never land. Any clues would be greatly appreciated. >> > > >> > > Best wishes, >> > > >> > > --greg >> >> I can't confirm it, with 6.8.3: >> >> $ ghc -O2 --make Monoidal.hs >> [1 of 1] Compiling Monoidal ( Monoidal.hs, Monoidal.o ) >> >> Monoidal.hs:110:11: >> Couldn't match expected type `i1' >> against inferred type `Isomorpism (HFTensorExpr a i) a' >> `i1' is a rigid type variable bound by >> the instance declaration at Monoidal.hs:103:42 >> In the expression: (PutIn (\ a -> (HFTLVal a))) >> In the third argument of `HFTExpr', namely >> `[(PutIn (\ a -> (HFTLVal a)))]' >> In the expression: >> (HFTExpr >> (HFTLVal a) >> (HFTRVal b) >> [(PutIn (\ a -> (HFTLVal a)))] >> [(PutIn (\ b -> (HFTRVal b)))]) >> $ >> >> and the earlier version: >> >> $ ghc -O2 --make Monoidal2.hs >> [1 of 1] Compiling Monoidal2 ( Monoidal2.hs, Monoidal2.o ) >> >> Monoidal2.hs:105:18: >> Couldn't match expected type `HFTensorExpr a i' >> against inferred type `[i1] -> [i1] -> HFTensorExpr a i1' >> In the expression: HFTExpr (HFTLVal a) (HFTRVal b) >> In the definition of `tMult': >> a tMult b = HFTExpr (HFTLVal a) (HFTRVal b) >> In the definition for method `tMult' >> >> Monoidal2.hs:122:10: >> Couldn't match expected type `[]' against inferred type `++ msa' >> Expected type: [i] >> Inferred type: ++ msa msb >> In the third argument of `HFTExpr', namely >> `((Shuffle >> (\ (HFTExpr (HFTExpr u v msu msv) w msuv msw) >> -> (tAssoc (HFTExpr (HFTExpr u v msu msv) w msuv msw)))) >> :: >> msa ++ msb)' >> In the expression: >> (HFTExpr >> (HFTExpr a b msa msb) >> c >> ((Shuffle >> (\ (HFTExpr (HFTExpr u v msu msv) w msuv msw) >> -> (tAssoc (HFTExpr (HFTExpr u v msu msv) w msuv >> msw)))) >> :: >> msa ++ msb) >> msc) >> >> Monoidal2.hs:139:10: >> Couldn't match expected type `[]' against inferred type `++ msl' >> Expected type: [i] >> Inferred type: ++ msl msr >> In the third argument of `HFTExpr', namely >> `((Shuffle >> (\ (HFTExpr (HFTExpr a b msa msb) c msab msc) >> -> (tAssoc (HFTExpr (HFTExpr a b msa msb) c msab msc)))) >> :: >> msl ++ msr)' >> In the expression: >> (HFTExpr >> (HFTExpr l r msl msr) >> (HFTRVal b) >> ((Shuffle >> (\ (HFTExpr (HFTExpr a b msa msb) c msab msc) >> -> (tAssoc (HFTExpr (HFTExpr a b msa msb) c msab >> msc)))) >> :: >> msl ++ msr) >> [(PutIn (\ b -> (HFTRVal b)))]) >> >> Monoidal2.hs:150:11: >> Couldn't match expected type `i1' >> against inferred type `Isomorpism (HFTensorExpr a i) a' >> `i1' is a rigid type variable bound by >> the instance declaration at Monoidal2.hs:103:42 >> In the expression: (PutIn (\ a -> (HFTRVal a))) >> In the third argument of `HFTExpr', namely >> `[(PutIn (\ a -> (HFTRVal a)))]' >> In the expression: >> (HFTExpr >> (HFTLVal a) >> (HFTRVal b) >> [(PutIn (\ a -> (HFTRVal a)))] >> [(PutIn (\ b -> (HFTRVal b)))]) >> $ >> >> No hang, which compiler version did you use? >> > > > > -- > L.G. Meredith > Managing Partner > Biosimilarity LLC > 806 55th St NE > Seattle, WA 98105 > > +1 206.650.3740 > > http://biosimilarity.blogspot.com > -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/90b68674/attachment.htm From mgg at giagnocavo.net Mon Dec 15 17:52:31 2008 From: mgg at giagnocavo.net (Michael Giagnocavo) Date: Mon Dec 15 17:46:21 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <4946D6EF.7040106@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> Message-ID: <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Don Stewart wrote: > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > Simple, clean and *pure*. > While "lambda in a circle" is quite powerful, it's also quite similar to the logo for the rather popular game "Half-Life" (especially if orange is used). I'm not sure if this is relevant. http://images.google.com/images?q=half+life+logo -Michael From dons at galois.com Mon Dec 15 17:55:11 2008 From: dons at galois.com (Don Stewart) Date: Mon Dec 15 17:47:51 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <20081215225511.GC31363@scytale.galois.com> mgg: > Don Stewart wrote: > > I noticed a new haskell logo idea on a tshirt today, > > > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > > > Simple, clean and *pure*. > > > > While "lambda in a circle" is quite powerful, it's also quite similar to the logo for the rather popular game "Half-Life" (especially if orange is used). I'm not sure if this is relevant. > http://images.google.com/images?q=half+life+logo > Haskell and Scheme have been using lambda in a circle for 20+ years, also... -- Don From daniel.is.fischer at web.de Mon Dec 15 18:06:38 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Dec 15 17:56:53 2008 Subject: [Haskell-cafe] Re: haskell compiler never comes back In-Reply-To: <5de3f5ca0812151449l30a42dc2q86887a1d84f04bba@mail.gmail.com> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> <200812152350.11554.daniel.is.fischer@web.de> <5de3f5ca0812151449l30a42dc2q86887a1d84f04bba@mail.gmail.com> Message-ID: <200812160006.38852.daniel.is.fischer@web.de> Am Montag, 15. Dezember 2008 23:49 schrieb Greg Meredith: > Daniel, > > Thanks. i'm using > > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Indeed, 6.8.2 hangs here, too. > Loading package base ... linking ... done. > Prelude> :l monoidal.hs > [1 of 1] Compiling Monoidal ( monoidal.hs, interpreted ) > C-c C-cInterrupted. > > > :q > > Best wishes, > > --greg > Cheers, Daniel From magnus at therning.org Mon Dec 15 18:08:40 2008 From: magnus at therning.org (Magnus Therning) Date: Mon Dec 15 18:01:33 2008 Subject: [Haskell-cafe] How to think about this? (profiling) Message-ID: <4946E378.4030109@therning.org> This behaviour by Haskell seems to go against my intuition, I'm sure I just need an update of my intuition ;-) I wanted to improve on the following little example code: foo :: Int -> Int foo 0 = 0 foo 1 = 1 foo 2 = 2 foo n = foo (n - 1) + foo (n - 2) + foo (n - 3) This is obviously going to run into problems for large values of `n` so I introduced a state to keep intermediate results in: foo :: Int -> State (UArray Int Int) Int foo 0 = return 0 foo 1 = return 1 foo 2 = return 2 foo n = do c <- get if (c ! n) /= -1 then return $ c ! n else do r <- liftM3 (\ a b c -> a + b + c) (foo $ n - 1) (foo $ n - 2) (foo $ n - 3) modify (\ s -> s // [(n, r)]) return r Then I added a convenience function and called it like this: createArray :: Int -> UArray Int Int createArray n = array (0, n) (zip [0..n] (repeat (-1))) main = do (n:_) <- liftM (map read) getArgs print $ evalState (foo n) (createArray n) Then I thought that this still looks pretty deeply recursive, but if I call the function for increasing values of `n` then I'll simply build up the state, sort of like doing a for-loop in an imperative language. I could then end it with a call to `foo n` and be done. I replaced `main` by: main = do (n:_) <- liftM (map read) getArgs print $ evalState (mapM_ foo [0..n] >> foo n) (createArray n) Then I started profiling and found out that the latter version both uses more memory and makes far more calls to `foo`. That's not what I expected! (I suspect there's something about laziness I'm missing.) Anyway, I ran it with `n=35` and got foo n : 202,048 bytes , foo entries 100 mapM_ foo [0..n] >> foo n : 236,312 , foo entries 135 + 1 How should I think about this in order to predict this behaviour in the future? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus Haskell is an even 'redder' pill than Lisp or Scheme. -- PaulPotts -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/353795fb/signature.bin From porges at porg.es Mon Dec 15 18:11:41 2008 From: porges at porg.es (George Pollard) Date: Mon Dec 15 18:04:30 2008 Subject: [Haskell-cafe] Re: haskell compiler never comes back In-Reply-To: <5de3f5ca0812151440x432fbf83vc2ad5494e4174db@mail.gmail.com> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> <5de3f5ca0812151416v20a67a3x59cb8a7abfb07a99@mail.gmail.com> <1229380447.11139.5.camel@porges-laptop> <5de3f5ca0812151440x432fbf83vc2ad5494e4174db@mail.gmail.com> Message-ID: <1229382701.13223.0.camel@porges-laptop> So I retract that email ;) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/bac4a83e/attachment.bin From s.clover at gmail.com Mon Dec 15 18:25:42 2008 From: s.clover at gmail.com (Sterling Clover) Date: Mon Dec 15 18:18:25 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081215225511.GC31363@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <20081215225511.GC31363@scytale.galois.com> Message-ID: Alvaro's infinity lambda is awesome! The fancy treatments -- shadows, reflections, and the funny haskell font can all go, but the infinity lambda is distinctive, conceptually clear, and conveys the notion that we're not just the lambda calculus, but the lambda calculus to the power of our type system. Speaking of which, maybe the lambda cube could be the basis for a logo? --S -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081215/f689f9f2/attachment.htm From lemmih at gmail.com Mon Dec 15 18:33:34 2008 From: lemmih at gmail.com (Lemmih) Date: Mon Dec 15 18:26:17 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: <4946E378.4030109@therning.org> References: <4946E378.4030109@therning.org> Message-ID: 2008/12/16 Magnus Therning : > This behaviour by Haskell seems to go against my intuition, I'm sure I > just need an update of my intuition ;-) > > I wanted to improve on the following little example code: > > foo :: Int -> Int > foo 0 = 0 > foo 1 = 1 > foo 2 = 2 > foo n = foo (n - 1) + foo (n - 2) + foo (n - 3) > > This is obviously going to run into problems for large values of `n` so > I introduced a state to keep intermediate results in: > > foo :: Int -> State (UArray Int Int) Int > foo 0 = return 0 > foo 1 = return 1 > foo 2 = return 2 > foo n = do > c <- get > if (c ! n) /= -1 > then return $ c ! n > else do > r <- liftM3 (\ a b c -> a + b + c) > (foo $ n - 1) (foo $ n - 2) (foo $ n - 3) > modify (\ s -> s // [(n, r)]) > return r > > Then I added a convenience function and called it like this: > > createArray :: Int -> UArray Int Int > createArray n = array (0, n) (zip [0..n] (repeat (-1))) > > main = do > (n:_) <- liftM (map read) getArgs > print $ evalState (foo n) (createArray n) > > Then I thought that this still looks pretty deeply recursive, but if I > call the function for increasing values of `n` then I'll simply build up > the state, sort of like doing a for-loop in an imperative language. I > could then end it with a call to `foo n` and be done. I replaced `main` > by: > > main = do > (n:_) <- liftM (map read) getArgs > print $ evalState (mapM_ foo [0..n] >> foo n) (createArray n) > > Then I started profiling and found out that the latter version both uses > more memory and makes far more calls to `foo`. That's not what I > expected! (I suspect there's something about laziness I'm missing.) > > Anyway, I ran it with `n=35` and got > > foo n : 202,048 bytes , foo entries 100 > mapM_ foo [0..n] >> foo n : 236,312 , foo entries 135 + 1 > > How should I think about this in order to predict this behaviour in the > future? Immutable arrays are duplicated every time you write to them. Making lots of small updates is going to be /very/ expensive. You have the right idea, though. Saving intermediate results is the right thing to do but arrays aren't the right way to do it. In this case, a lazy list will perform much better. > ack n = ackList !! n > where ackList = 0:1:2:zipWith3 (\a b c -> a+b+c) ackList (drop 1 ackList) (drop 2 ackList) -- Cheers, Lemmih From derek.a.elkins at gmail.com Mon Dec 15 18:39:07 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Dec 15 18:31:57 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <20081215225511.GC31363@scytale.galois.com> Message-ID: <1229384347.6354.19.camel@derek-laptop> On Mon, 2008-12-15 at 18:25 -0500, Sterling Clover wrote: > Alvaro's infinity lambda is awesome! The fancy treatments -- shadows, > reflections, and the funny haskell font can all go, but the infinity > lambda is distinctive, conceptually clear, and conveys the notion that > we're not just the lambda calculus, but the lambda calculus to the > power of our type system. Speaking of which, maybe the lambda cube > could be the basis for a logo? Haskell sits in the middle of one of the faces of the lambda cube, possibly even a bit in the volume, though I don't think so. From isaacdupree at charter.net Mon Dec 15 18:52:00 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Mon Dec 15 18:44:51 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081215225511.GC31363@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <20081215225511.GC31363@scytale.galois.com> Message-ID: <4946EDA0.6080907@charter.net> okay, I want a t-shirt like this (but with all the greek letters and formatting) back: \t. 2^-t kg is equally[or: sometimes] bothered by math front: \gbtq is [sometimes] bothered by acronyms :-) or, sometimes likes each of them :-) -Isaac From alexander.dunlap at gmail.com Mon Dec 15 19:11:49 2008 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Mon Dec 15 19:04:32 2008 Subject: [Haskell-cafe] Multi-parameter type class woes In-Reply-To: <4946601A.6000900@stilo.com> References: <.1229314200@magma.ca> <57526e770812142045w255fb42bwb882e435f2fa61eb@mail.gmail.com> <4946601A.6000900@stilo.com> Message-ID: <57526e770812151611r451c36b4o20122c58ad2c6f5e@mail.gmail.com> 2008/12/15 Mario Blazevic : > Alexander Dunlap wrote: >> >> On Sun, Dec 14, 2008 at 8:10 PM, Mario Bla?evi? >> wrote: >>>> >>>> I'll take a swing at this one: >>>> >>>> instance Container (Maybe x) [x] where >>>> wrapper = isNothing >>>> . . . >>>> >>>> That isn't a sensible definition of 'wrapper', but I believe without >>>> trying to compile it is completely legal. Which wrapper do you use? >>>> >>>> You /don't/ have a different matching Container instance, but without >>>> the >>>> functional dependency you /might/, and ghc barfs. >>> >>> But liftWrap doesn't require any particular instance, it's a >>> generic function accepting any pair of types for which there is >>> an instance of Container. Instance selection (as I understand it) >>> shouldn't come into play until one applies liftWrap to a >>> particular type, and indeed it does cause problems there: note >>> the type annotations on the last line. That part I understand >>> and accept, or at least have learned to live with. >> >> The problem is that y is not mentioned in the signature of wrapper. >> When you call wrapper x, there could be many different instances of >> Container x y with the same x, so GHC doesn't know which version to >> call. > > > I guess I see it now. However, if the explicit 'Container x y =>' > context couldn't fix the y to use for instantiation of Container x y, I > don't see any way to fix it. And if there is no way to call wrapper in any > context, the class declaration itself is illegal and GHC should have > reported the error much sooner. Should I create a ticket? > > > >> You can fix this problem either by adding a functional >> dependency or by splitting wrapper out into its own class (Wrapper x, >> e.g.) so all of the type variables in the class head are mentioned in >> its type and the instance can be determined by the call. >> >> Thanks for asking this question, by the way. I had known about this >> issue but had never really realized why it happened. Now that I have >> thought about it, I understand it too. :) >> >> Hope that helps, >> Alex >> > > I think that http://www.haskell.org/pipermail/haskell-cafe/2008-April/041461.html may be relevant. It's a design decision. Alex From porges at porg.es Mon Dec 15 21:45:49 2008 From: porges at porg.es (George Pollard) Date: Mon Dec 15 21:39:39 2008 Subject: [Haskell-cafe] Minimal complete definitions Message-ID: <1229395549.13223.32.camel@porges-laptop> Good afternoon Caf?, I've written a little bit of code to calculate minimal complete definitions for a class given which of its functions use which other functions. As an example: doDependencies ord = ([],[["<="],["compare"]]) doDependencies num = (["plus","times","abs","signum","fromInteger"],[["minus"],["negate"]]) The first part of the pair is those functions which must *always* be implemented, the second part is a list of possible minimal complete definitions available for the provided list. This can help catch mistakes; a comment in the GHC source for GHC.Classes notes that compare must be implemented using (<=) and not (<) in order to give the minimal complete definition (<= OR compare). If we use the incorrect (<) then my code calculates the MCD as: doDependencies wrongOrd = ([],[["<"],["<","<=","compare"],["compare"]]) That is, the MCD is (< OR (< AND <= AND compare) OR compare). Now I have two questions: 1) Is my code correct? ;) 2) Could this be incorporated into GHC in order to detect when someone hasn't provided a sufficient definition for a class? As an example, it could detect this: > ~$ cat test2.hs > data Die d = Die d > instance Eq (Die d) where > main = do > let i = Die "stack overflow" > print (i == i) > ~$ ghc -Wall test2.hs --make > ~$ ./test2 > Stack space overflow: current size 8388608 bytes. > Use `+RTS -Ksize' to increase it. Given the following: doDependencies [("==", Just ["/="]),("/=", Just ["=="])] = ([],[["/="],["=="]]) GHC could warn that either (==) or (/=) must be implemented. Thanks, - George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/4eaad080/attachment.bin From porges at porg.es Mon Dec 15 21:55:26 2008 From: porges at porg.es (George Pollard) Date: Mon Dec 15 21:49:12 2008 Subject: [Haskell-cafe] Minimal complete definitions In-Reply-To: <1229395549.13223.32.camel@porges-laptop> References: <1229395549.13223.32.camel@porges-laptop> Message-ID: <1229396126.13223.33.camel@porges-laptop> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/7d43c81b/attachment.bin From porges at porg.es Mon Dec 15 22:06:50 2008 From: porges at porg.es (George Pollard) Date: Mon Dec 15 21:59:41 2008 Subject: [Haskell-cafe] Minimal complete definitions In-Reply-To: <1229396126.13223.33.camel@porges-laptop> References: <1229395549.13223.32.camel@porges-laptop> <1229396126.13223.33.camel@porges-laptop> Message-ID: <1229396810.13223.37.camel@porges-laptop> Sorry about the triple-post, but I forgot to note it only goes to one 'depth' of OR; in reality the MCD for wrongOrd should be (< OR ((<=) AND (compare OR <)) OR compare). This requires a slightly more complicated type than [[a]] :) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/2d78fbd8/attachment.bin From mblazevic at stilo.com Mon Dec 15 22:58:46 2008 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Mon Dec 15 22:51:27 2008 Subject: [Haskell-cafe] Multi-parameter type class woes Message-ID: <.1229399926@magma.ca> > I think that http://www.haskell.org/pipermail/haskell-cafe/2008-April/041461.html > may be relevant. It's a design decision. Thanks for the link. I've read through the thread, but rather than try to figure out if it's the same issue and whether it's a design decision or a historical accident, I've decided to create a ticket (#2885) and let GHC developers decide if it's valid or not. From jagrhask at gmail.com Tue Dec 16 02:52:37 2008 From: jagrhask at gmail.com (jagrhask) Date: Tue Dec 16 02:46:31 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <49475E45.3000202@gmail.com> What do you think about this logo? I'm not a good painter but just to illustrate idea: lazy lambda taking rest laying under tree and some blinks symbolize how is it. I hope somebody could draw it better. Don Stewart ?????: > I noticed a new haskell logo idea on a tshirt today, > > http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png > > Simple, clean and *pure*. > > Instead of the "we got lots going on" of the current logo. > > Any graphic designers want to try some variations on this theme of > purity? > > A new year, and a new mature logo... > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- A non-text attachment was scrubbed... Name: lambda1.jpg Type: image/jpeg Size: 9228 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/46afa12d/lambda1.jpg From jagrhask at gmail.com Tue Dec 16 03:01:09 2008 From: jagrhask at gmail.com (jagrhask) Date: Tue Dec 16 02:54:04 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49475E45.3000202@gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <49475E45.3000202@gmail.com> Message-ID: <49476045.2030501@gmail.com> jagrhask ?????: > What do you think about this logo? > I'm not a good painter but just to illustrate idea: > lazy lambda taking rest laying under tree and some blinks symbolize > how is it. Of course "symbolize how clean is it". > I hope somebody could draw it better. > > Don Stewart ?????: >> I noticed a new haskell logo idea on a tshirt today, >> >> http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png >> >> >> Simple, clean and *pure*. >> >> Instead of the "we got lots going on" of the current logo. >> >> Any graphic designers want to try some variations on this theme of >> purity? >> A new year, and a new mature logo... >> >> -- Don >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > > ------------------------------------------------------------------------ > From miguelimo38 at yandex.ru Tue Dec 16 03:16:35 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Dec 16 03:09:30 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49475E45.3000202@gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <49475E45.3000202@gmail.com> Message-ID: <4ED85E4B-615E-48E4-BFA9-184A685BBB83@yandex.ru> Sorry to disappoint you, but the "tree" is not the very first thing that comes to mind when you look at this drawing. And, despite that it satisfies Don's condition to be "mature" (though "adult" would be a better word), this kind of pornography is NOT, I believe, what most of us want for a Haskell logo. On 16 Dec 2008, at 10:52, jagrhask wrote: > What do you think about this logo? > I'm not a good painter but just to illustrate idea: > lazy lambda taking rest laying under tree and some blinks symbolize > how is it. > I hope somebody could draw it better. > > Don Stewart ?????: >> I noticed a new haskell logo idea on a tshirt today, >> http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png >> >> Simple, clean and *pure*. >> >> Instead of the "we got lots going on" of the current logo. >> >> Any graphic designers want to try some variations on this theme of >> purity? >> A new year, and a new mature logo... >> >> -- Don >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ndmitchell at gmail.com Tue Dec 16 03:45:54 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Dec 16 03:38:38 2008 Subject: [Haskell-cafe] Re: [Haskell] Missing Documentation In-Reply-To: <132824.25314.qm@web50912.mail.re2.yahoo.com> References: <132824.25314.qm@web50912.mail.re2.yahoo.com> Message-ID: <404396ef0812160045h370b280cib521488b7a39ccc4@mail.gmail.com> Hi Ron > This may very well be a FAQ, but I tried to search the archives and could not find a post... > Anyway, some documentation seems to be missing, which was there before I thought. For example: > http://www.haskell.org/ghc/docs/latest/html/libraries/haskell98/Random.html That's a bug, I've reported it here: http://hackage.haskell.org/trac/ghc/ticket/2886 > Thanks, and sorry if this lowers the S/N We usually use haskell@ for annoucements, and haskell-cafe@ for general discussion/questions etc, so in future these kinds of posts should go on that mailing list. It's a confusing system! Any follow ups to this post should also only go to haskell-cafe@ Thanks Neil From jagrhask at gmail.com Tue Dec 16 03:52:52 2008 From: jagrhask at gmail.com (jagrhask) Date: Tue Dec 16 03:45:48 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <4ED85E4B-615E-48E4-BFA9-184A685BBB83@yandex.ru> References: <20081214211504.GO27904@scytale.galois.com> <49475E45.3000202@gmail.com> <4ED85E4B-615E-48E4-BFA9-184A685BBB83@yandex.ru> Message-ID: <49476C64.8050602@gmail.com> Miguel Mitrofanov ?????: > Sorry to disappoint you, but the "tree" is not the very first thing > that comes to mind when you look at this drawing. And, despite that it > satisfies As I already said, I'm not good in drawing, so if somthing bad comes to your mind looking at this tree - just draw it so that it would look like real tree. I'm not a designer I've just wanted to illustrate my idea for sombody who could draw it properly. > Don's condition to be "mature" (though "adult" would be a better > word), this kind of pornography is NOT, I believe, what most of us > want for a Haskell logo. If somebody want to find pornography, he'll find it even in blank list. BTW. I would like to know what you found in this sketch (please let me know in private message, to not be sued for prnography distribution :) ). > > On 16 Dec 2008, at 10:52, jagrhask wrote: > >> What do you think about this logo? >> I'm not a good painter but just to illustrate idea: >> lazy lambda taking rest laying under tree and some blinks symbolize >> how is it. >> I hope somebody could draw it better. >> >> Don Stewart ?????: >>> I noticed a new haskell logo idea on a tshirt today, >>> >>> http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png >>> >>> >>> Simple, clean and *pure*. >>> >>> Instead of the "we got lots going on" of the current logo. >>> >>> Any graphic designers want to try some variations on this theme of >>> purity? >>> A new year, and a new mature logo... >>> >>> -- Don >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From gianfranco.alongi at gmail.com Tue Dec 16 05:13:20 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Tue Dec 16 05:06:24 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49476C64.8050602@gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <49475E45.3000202@gmail.com> <4ED85E4B-615E-48E4-BFA9-184A685BBB83@yandex.ru> <49476C64.8050602@gmail.com> Message-ID: Obviously there are a lot of different wills in this discussion, and I propose we take this to the next level by letting people submit all their ideas to the Haskell wiki page, and vote later on. /Gf On Tue, Dec 16, 2008 at 9:52 AM, jagrhask wrote: > Miguel Mitrofanov ?????: >> >> Sorry to disappoint you, but the "tree" is not the very first thing that >> comes to mind when you look at this drawing. And, despite that it satisfies > > As I already said, I'm not good in drawing, so if somthing bad comes to your > mind looking at this tree - just draw it so that it would look like real > tree. I'm not a designer I've just wanted to illustrate my idea for sombody > who could draw it properly. >> >> Don's condition to be "mature" (though "adult" would be a better word), >> this kind of pornography is NOT, I believe, what most of us want for a >> Haskell logo. > > If somebody want to find pornography, he'll find it even in blank list. > BTW. I would like to know what you found in this sketch (please let me know > in private message, to not be sued for prnography distribution :) ). >> >> On 16 Dec 2008, at 10:52, jagrhask wrote: >> >>> What do you think about this logo? >>> I'm not a good painter but just to illustrate idea: >>> lazy lambda taking rest laying under tree and some blinks symbolize how >>> is it. >>> I hope somebody could draw it better. >>> >>> Don Stewart ?????: >>>> >>>> I noticed a new haskell logo idea on a tshirt today, >>>> >>>> http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png >>>> >>>> Simple, clean and *pure*. >>>> >>>> Instead of the "we got lots going on" of the current logo. >>>> >>>> Any graphic designers want to try some variations on this theme of >>>> purity? >>>> A new year, and a new mature logo... >>>> >>>> -- Don >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Patience is the last resort for those unable to take action From mozhgan_kch at hotmail.com Tue Dec 16 05:47:08 2008 From: mozhgan_kch at hotmail.com (Mozhgan Kabiri) Date: Tue Dec 16 05:39:50 2008 Subject: [Haskell-cafe] MVar and Par .. Message-ID: Hi .. Hope you are doing well . I've just joined this group. Recently, I am struggling to do some simple experiment with haskell language about parallelism and wrong answers that we can get while using a shared variable . I tried to write a simple program, for example calculationg 'n=n+1' few times.And then I tried to do it in parallel by using 'par' and 'pseq' . The aim was to get the wrong answer because we have to share a variable here,and without using 'MVar' function we will get the wrong answer for the calculation .I don't know how to write it in parallel in order to get a wrong answer when we don't use MVar,because we have a shared variable here. I read about MVars as well,but also I don't know how to combine MVar and Par together to get the program to work.I wrote this :module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n | x <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do putStrLn "starting..." let r = f 10 5 putStrLn (show r) putStrLn "finished" I want to make to work in parallel by using 'Par'.And also use MVar for this simple example to work.All of the example about MVar are a little bit complicated and I couldn't figure it that how can I write one,the same !Can any one help me with this ? I want a simple example that I can feel the need of MVar when I run my program in parallel and while I am using a shared variable.Regards; Mozhgan _________________________________________________________________ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/38494f27/attachment.htm From mozhgan_kch at hotmail.com Tue Dec 16 05:49:08 2008 From: mozhgan_kch at hotmail.com (Mozhgan Kabiri) Date: Tue Dec 16 05:41:49 2008 Subject: [Haskell-cafe] MVar and Par .. Message-ID: Hi .. Hope you are doing well . I've just joined this group. Recently, I am struggling to do some simple experiment with haskell language about parallelism and wrong answers that we can get while using a shared variable . I tried to write a simple program, for example calculationg 'n=n+1' few times.And then I tried to do it in parallel by using 'par' and 'pseq' . The aim was to get the wrong answer because we have to share a variable here,and without using 'MVar' function we will get the wrong answer for the calculation .I don't know how to write it in parallel in order to get a wrong answer when we don't use MVar,because we have a shared variable here. I read about MVars as well,but also I don't know how to combine MVar and Par together to get the program to work.I wrote this :module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n | x <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do putStrLn "starting..." let r = f 10 5 putStrLn (show r) putStrLn "finished" I want to make to work in parallel by using 'Par'.And also use MVar for this simple example to work.All of the example about MVar are a little bit complicated and I couldn't figure it that how can I write one,the same !Can any one help me with this ? I want a simple example that I can feel the need of MVar when I run my program in parallel and while I am using a shared variable.Regards; Mozhgan Get news, entertainment and everything you care about at Live.com. Check it out! _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/dcfcb18a/attachment.htm From lrpalmer at gmail.com Tue Dec 16 06:03:59 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Dec 16 05:56:42 2008 Subject: [Haskell-cafe] MVar and Par .. In-Reply-To: References: Message-ID: <7ca3f0160812160303j1dca1135k5f628fd636989777@mail.gmail.com> 2008/12/16 Mozhgan Kabiri > Hi .. Hope you are doing well . I've just joined this group. > Recently, I am struggling to do some simple experiment with haskell > language about parallelism and wrong answers that we can get while using a > shared variable . > I tried to write a simple program, for example calculationg 'n=n+1' few > times.And then I tried to do it in parallel by using 'par' and 'pseq' . The > aim was to get the wrong answer because we have to share a variable here,and > without using 'MVar' function we will get the wrong answer for the > calculation . > This is fortunately impossible. par can never change the semantics of a program; it just says "compute this in parallel now because we might need it later", as opposed to just computing it later when it is demanded. Because Haskell is referentially transparent, the answer it will get now vs. later will always be the same. Race conditions cannot happen with par. Perhaps you want to experiment with concurrency rather than parallelism (this is the realm in which MVars lie). In that case, look at the function forkIO, which spawns a new thread, and the MVar operations. Luke > I don't know how to write it in parallel in order to get a wrong answer > when we don't use MVar,because we have a shared variable here. I read about > MVars as well,but also I don't know how to combine MVar and Par together to > get the program to work. > > I wrote this : > > module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n | x > <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do putStrLn > "starting..." let r = f 10 5 putStrLn (show r) putStrLn "finished" > I want to make to work in parallel by using 'Par'.And also use MVar for > this simple example to work. > All of the example about MVar are a little bit complicated and I couldn't > figure it that how can I write one,the same ! > > Can any one help me with this ? I want a simple example that I can feel the > need of MVar when I run my program in parallel and while I am using a shared > variable. > > Regards; Mozhgan > > > ------------------------------ > Get news, entertainment and everything you care about at Live.com. Check > it out! > > _______________________________________________ > 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/20081216/23e0901a/attachment-0001.htm From mozhgan_kch at hotmail.com Tue Dec 16 06:13:08 2008 From: mozhgan_kch at hotmail.com (Mozhgan Kabiri) Date: Tue Dec 16 06:05:49 2008 Subject: [Haskell-cafe] MVar and Par .. In-Reply-To: <7ca3f0160812160303j1dca1135k5f628fd636989777@mail.gmail.com> References: <7ca3f0160812160303j1dca1135k5f628fd636989777@mail.gmail.com> Message-ID: Hi ..Hmm .. maybe I explained it badly.For example I want my two processor to do two tasks while they are sharing a variable . Is it not parallelism ? We don't need MVar, as well ? I completely misunderstood !MozhganDate: Tue, 16 Dec 2008 04:03:59 -0700From: lrpalmer@gmail.comTo: mozhgan_kch@hotmail.comSubject: Re: [Haskell-cafe] MVar and Par ..CC: haskell-cafe@haskell.org2008/12/16 Mozhgan Kabiri Hi .. Hope you are doing well . I've just joined this group. Recently, I am struggling to do some simple experiment with haskell language about parallelism and wrong answers that we can get while using a shared variable . I tried to write a simple program, for example calculationg 'n=n+1' few times.And then I tried to do it in parallel by using 'par' and 'pseq' . The aim was to get the wrong answer because we have to share a variable here,and without using 'MVar' function we will get the wrong answer for the calculation . This is fortunately impossible. par can never change the semantics of a program; it just says "compute this in parallel now because we might need it later", as opposed to just computing it later when it is demanded. Because Haskell is referentially transparent, the answer it will get now vs. later will always be the same. Race conditions cannot happen with par. Perhaps you want to experiment with concurrency rather than parallelism (this is the realm in which MVars lie). In that case, look at the function forkIO, which spawns a new thread, and the MVar operations. Luke I don't know how to write it in parallel in order to get a wrong answer when we don't use MVar,because we have a shared variable here. I read about MVars as well,but also I don't know how to combine MVar and Par together to get the program to work. I wrote this : module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n | x <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do putStrLn "starting..." let r = f 10 5 putStrLn (show r) putStrLn "finished" I want to make to work in parallel by using 'Par'.And also use MVar for this simple example to work. All of the example about MVar are a little bit complicated and I couldn't figure it that how can I write one,the same ! Can any one help me with this ? I want a simple example that I can feel the need of MVar when I run my program in parallel and while I am using a shared variable. Regards; Mozhgan Get news, entertainment and everything you care about at Live.com. Check it out! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/0e94cd5d/attachment.htm From magnus at therning.org Tue Dec 16 07:07:20 2008 From: magnus at therning.org (Magnus Therning) Date: Tue Dec 16 07:00:40 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: References: <4946E378.4030109@therning.org> Message-ID: On Mon, Dec 15, 2008 at 11:33 PM, Lemmih wrote: > 2008/12/16 Magnus Therning : >> This behaviour by Haskell seems to go against my intuition, I'm sure I >> just need an update of my intuition ;-) >> >> I wanted to improve on the following little example code: >> >> foo :: Int -> Int >> foo 0 = 0 >> foo 1 = 1 >> foo 2 = 2 >> foo n = foo (n - 1) + foo (n - 2) + foo (n - 3) >> >> This is obviously going to run into problems for large values of `n` so >> I introduced a state to keep intermediate results in: >> >> foo :: Int -> State (UArray Int Int) Int >> foo 0 = return 0 >> foo 1 = return 1 >> foo 2 = return 2 >> foo n = do >> c <- get >> if (c ! n) /= -1 >> then return $ c ! n >> else do >> r <- liftM3 (\ a b c -> a + b + c) >> (foo $ n - 1) (foo $ n - 2) (foo $ n - 3) >> modify (\ s -> s // [(n, r)]) >> return r >> >> Then I added a convenience function and called it like this: >> >> createArray :: Int -> UArray Int Int >> createArray n = array (0, n) (zip [0..n] (repeat (-1))) >> >> main = do >> (n:_) <- liftM (map read) getArgs >> print $ evalState (foo n) (createArray n) >> >> Then I thought that this still looks pretty deeply recursive, but if I >> call the function for increasing values of `n` then I'll simply build up >> the state, sort of like doing a for-loop in an imperative language. I >> could then end it with a call to `foo n` and be done. I replaced `main` >> by: >> >> main = do >> (n:_) <- liftM (map read) getArgs >> print $ evalState (mapM_ foo [0..n] >> foo n) (createArray n) >> >> Then I started profiling and found out that the latter version both uses >> more memory and makes far more calls to `foo`. That's not what I >> expected! (I suspect there's something about laziness I'm missing.) >> >> Anyway, I ran it with `n=35` and got >> >> foo n : 202,048 bytes , foo entries 100 >> mapM_ foo [0..n] >> foo n : 236,312 , foo entries 135 + 1 >> >> How should I think about this in order to predict this behaviour in the >> future? > > Immutable arrays are duplicated every time you write to them. Making > lots of small updates is going to be /very/ expensive. > You have the right idea, though. Saving intermediate results is the > right thing to do but arrays aren't the right way to do it. In this > case, a lazy list will perform much better. > >> ack n = ackList !! n >> where ackList = 0:1:2:zipWith3 (\a b c -> a+b+c) ackList (drop 1 ackList) (drop 2 ackList) Ah, OK that does explain it. I understand your solution, but AFAICS it's geared towards limited recursion in a sense. What if I want to use memoization to speed up something like this foo :: Int -> Int foo 0 = 0 foo 1 = 1 foo 2 = 2 foo n = sum [foo i | i <- [0..n - 1]] That is, where each value depends on _all_ preceding values. AFAIK list access is linear, is there a type that is a more suitable state for this changed problem? I realise this particular function can be written using scanl: foo :: Int -> Int foo n = ackList !! n where ackList = 0:1:2:(drop 2 $ scanl1 (+) ackList) but I guess it's not always that easy to construct a solution based on scanl. Cheers, M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From Malcolm.Wallace at cs.york.ac.uk Tue Dec 16 07:12:17 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Dec 16 07:07:36 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <4946D6EF.7040106@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> Message-ID: <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> Andrew Coppin wrote: > To him, apparently, the current logo says "Haskell is all > about arcane and obscure mathematical constructs. In fact, we think > that complicated mathematics is so good that we stuffed our logo full > of it. If you don't like hard math, don't even bother trying to learn > this language." I think he got the right idea (kind of). To him, mathematics is arcane, but to Haskellers it is the fundamental basis of computation. If someone is not prepared to invest in learning the foundations of the subject of Computer Science, then they have no business becoming a programmer. Would you want someone who disdains mathematics to be responsible for designing the physical aerodynamics of aircraft? Then why would you permit them to program the control software that will fly it? We really must get away from the idea that programming is something any old fool should be able to pick up. Programming correct software is hard, and it requires a mathematical mind. Regards, Malcolm From lemmih at gmail.com Tue Dec 16 07:14:17 2008 From: lemmih at gmail.com (Lemmih) Date: Tue Dec 16 07:07:52 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: References: <4946E378.4030109@therning.org> Message-ID: On Tue, Dec 16, 2008 at 1:07 PM, Magnus Therning wrote: > On Mon, Dec 15, 2008 at 11:33 PM, Lemmih wrote: >> 2008/12/16 Magnus Therning : >>> This behaviour by Haskell seems to go against my intuition, I'm sure I >>> just need an update of my intuition ;-) >>> >>> I wanted to improve on the following little example code: >>> >>> foo :: Int -> Int >>> foo 0 = 0 >>> foo 1 = 1 >>> foo 2 = 2 >>> foo n = foo (n - 1) + foo (n - 2) + foo (n - 3) >>> >>> This is obviously going to run into problems for large values of `n` so >>> I introduced a state to keep intermediate results in: >>> >>> foo :: Int -> State (UArray Int Int) Int >>> foo 0 = return 0 >>> foo 1 = return 1 >>> foo 2 = return 2 >>> foo n = do >>> c <- get >>> if (c ! n) /= -1 >>> then return $ c ! n >>> else do >>> r <- liftM3 (\ a b c -> a + b + c) >>> (foo $ n - 1) (foo $ n - 2) (foo $ n - 3) >>> modify (\ s -> s // [(n, r)]) >>> return r >>> >>> Then I added a convenience function and called it like this: >>> >>> createArray :: Int -> UArray Int Int >>> createArray n = array (0, n) (zip [0..n] (repeat (-1))) >>> >>> main = do >>> (n:_) <- liftM (map read) getArgs >>> print $ evalState (foo n) (createArray n) >>> >>> Then I thought that this still looks pretty deeply recursive, but if I >>> call the function for increasing values of `n` then I'll simply build up >>> the state, sort of like doing a for-loop in an imperative language. I >>> could then end it with a call to `foo n` and be done. I replaced `main` >>> by: >>> >>> main = do >>> (n:_) <- liftM (map read) getArgs >>> print $ evalState (mapM_ foo [0..n] >> foo n) (createArray n) >>> >>> Then I started profiling and found out that the latter version both uses >>> more memory and makes far more calls to `foo`. That's not what I >>> expected! (I suspect there's something about laziness I'm missing.) >>> >>> Anyway, I ran it with `n=35` and got >>> >>> foo n : 202,048 bytes , foo entries 100 >>> mapM_ foo [0..n] >> foo n : 236,312 , foo entries 135 + 1 >>> >>> How should I think about this in order to predict this behaviour in the >>> future? >> >> Immutable arrays are duplicated every time you write to them. Making >> lots of small updates is going to be /very/ expensive. >> You have the right idea, though. Saving intermediate results is the >> right thing to do but arrays aren't the right way to do it. In this >> case, a lazy list will perform much better. >> >>> ack n = ackList !! n >>> where ackList = 0:1:2:zipWith3 (\a b c -> a+b+c) ackList (drop 1 ackList) (drop 2 ackList) > > Ah, OK that does explain it. > > I understand your solution, but AFAICS it's geared towards limited > recursion in a sense. What if I want to use memoization to speed up > something like this > > foo :: Int -> Int > foo 0 = 0 > foo 1 = 1 > foo 2 = 2 > foo n = sum [foo i | i <- [0..n - 1]] > > That is, where each value depends on _all_ preceding values. AFAIK > list access is linear, is there a type that is a more suitable state > for this changed problem? You could use a Map or a mutable array. However, this kind of problem comes up a lot less often than you'd think. -- Cheers, Lemmih From felipe.lessa at gmail.com Tue Dec 16 07:19:33 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Dec 16 07:12:14 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: References: <4946E378.4030109@therning.org> Message-ID: 2008/12/16 Magnus Therning : > That is, where each value depends on _all_ preceding values. AFAIK > list access is linear, is there a type that is a more suitable state > for this changed problem? > > I realise this particular function can be written using scanl: [...] > but I guess it's not always that easy to construct a solution based on scanl. You can always write something like > foo :: Int -> Int > foo = (vals !!) > where > vals = map foo' [0..] > foo' 0 = 0 > foo' 1 = 1 > foo' 2 = 2 > foo' n = sum $ map foo [0..n-1] which doesn't prevent you from using whatever recursive case you want. Note that if your recursive case depends on all preceding values, then you can't do better than using a linear access data structure like a list unless you need random access. I should point out as well that there are some packages on Hackage for memoization, like: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-memocombinators http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MemoTrie -- Felipe. From haskell at list.mightyreason.com Tue Dec 16 07:34:23 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Dec 16 07:27:16 2008 Subject: [Haskell-cafe] Re: MVar and Par .. In-Reply-To: References: Message-ID: <4947A04F.6060801@list.mightyreason.com> Mozhgan Kabiri wrote: > Hi .. Hope you are doing well . I've just joined this group. Hi. > Recently, I am struggling to do some simple experiment with haskell > language about parallelism and wrong answers that we can get while using > a shared variable . Your goal is still unclear. Are you trying to create an example which shows unexpected answers? Are you trying to create an example which shows the expected answer? > I tried to write a simple program, for example calculationg 'n=n+1' few > times.And then I tried to do it in parallel by using 'par' and 'pseq' . > The aim was to get the wrong answer because we have to share a variable > here,and without using 'MVar' function we will get the wrong answer for > the calculation . MVar is a mutable storage cell. One can use forkIO to create IO threads which race to change MVar, and if this is done badly then you can get unexpected answers. One cannot use the pure "par" and "pseq" to launch IO threads, so you cannot use "par" and "pseq" to create race conditions, so one can only get the expected answer. > I don't know how to write it in parallel in order to get a wrong answer > when we don't use MVar,because we have a shared variable here. I read > about MVars as well,but also I don't know how to combine MVar and Par > together to get the program to work. I do not immediately see how MVar and "par" can be sensibly combined at all. > I wrote this : > > module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n | > x <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do > putStrLn "starting..." let r = f 10 5 putStrLn (show r) putStrLn "finished" > I want to make to work in parallel by using 'Par'.And also use MVar for > this simple example to work. > All of the example about MVar are a little bit complicated and I > couldn't figure it that how can I write one,the same ! > > Can any one help me with this ? I want a simple example that I can feel > the need of MVar when I run my program in parallel and while I am using > a shared variable. > > Regards; Mozhgan I have run out of time, so I leave this part of your question to others. From mozhgan_kch at hotmail.com Tue Dec 16 07:40:50 2008 From: mozhgan_kch at hotmail.com (Mozhgan Kabiri) Date: Tue Dec 16 07:33:31 2008 Subject: [Haskell-cafe] Re: MVar and Par .. In-Reply-To: <4947A04F.6060801@list.mightyreason.com> References: <4947A04F.6060801@list.mightyreason.com> Message-ID: Hi , Yeah , first I want to get unexpected answer ! And then I want to prove that when I use MVar I will get the write answer.I want to show that when we have a shared variable, we should use MVar.Besides we use for example two processors to do different tasks.But the point is these processors have to share a variable and I want to show it with MVar.But I don't know how to write a simple code to show it while undrestand it. Mozhgan > To: haskell-cafe@haskell.org > From: haskell@list.mightyreason.com > Date: Tue, 16 Dec 2008 12:34:23 +0000 > Subject: [Haskell-cafe] Re: MVar and Par .. > > Mozhgan Kabiri wrote: > > Hi .. Hope you are doing well . I've just joined this group. > > Hi. > > > Recently, I am struggling to do some simple experiment with haskell > > language about parallelism and wrong answers that we can get while using > > a shared variable . > > Your goal is still unclear. > Are you trying to create an example which shows unexpected answers? > Are you trying to create an example which shows the expected answer? > > > I tried to write a simple program, for example calculationg 'n=n+1' few > > times.And then I tried to do it in parallel by using 'par' and 'pseq' . > > The aim was to get the wrong answer because we have to share a variable > > here,and without using 'MVar' function we will get the wrong answer for > > the calculation . > > MVar is a mutable storage cell. One can use forkIO to create IO threads which > race to change MVar, and if this is done badly then you can get unexpected answers. > > One cannot use the pure "par" and "pseq" to launch IO threads, so you cannot use > "par" and "pseq" to create race conditions, so one can only get the expected answer. > > > I don't know how to write it in parallel in order to get a wrong answer > > when we don't use MVar,because we have a shared variable here. I read > > about MVars as well,but also I don't know how to combine MVar and Par > > together to get the program to work. > > I do not immediately see how MVar and "par" can be sensibly combined at all. > > > I wrote this : > > > > module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n | > > x <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do > > putStrLn "starting..." let r = f 10 5 putStrLn (show r) putStrLn "finished" > > I want to make to work in parallel by using 'Par'.And also use MVar for > > this simple example to work. > > All of the example about MVar are a little bit complicated and I > > couldn't figure it that how can I write one,the same ! > > > > Can any one help me with this ? I want a simple example that I can feel > > the need of MVar when I run my program in parallel and while I am using > > a shared variable. > > > > Regards; Mozhgan > > I have run out of time, so I leave this part of your question to others. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/9a6173d8/attachment.htm From lrpalmer at gmail.com Tue Dec 16 07:54:40 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Dec 16 07:47:21 2008 Subject: [Haskell-cafe] Re: MVar and Par .. In-Reply-To: References: <4947A04F.6060801@list.mightyreason.com> Message-ID: <7ca3f0160812160454s72888e26w8292c43f5b8e194a@mail.gmail.com> Okay, that's a bit clearer. Control.Parallel is not what you want; that is for parallelizing pure code (and is very nice inside its little domain). But you want concurrent code: multiple threads that change state at the same time. That is in Control.Concurrent. In particular, the "shared variable" is Data.IORef. Simple example from which you should be able to extrapolate. import Control.Concurrent import Control.Concurrent.MVar import Data.IORef threadBody = do x <- readIORef var writeIORef var (x+1) main = do var <- newIORef 0 -- spawn two threads forkIO threadBody forkIO threadBody -- look at the value of the variable x <- readIORef var print x You can scatter threadDelay throughout this code to mess with the scheduler and show how a failure could happen. Conversion to MVars should be pretty straightforward. Luke 2008/12/16 Mozhgan Kabiri > > Hi , > > Yeah , first I want to get unexpected answer ! And then I want to prove > that when I use MVar I will get the write answer.I want to show that when we > have a shared variable, we should use MVar.Besides we use for example two > processors to do different tasks.But the point is these processors have to > share a variable and I want to show it with MVar.But I don't know how to > write a simple code to show it while undrestand it. > > Mozhgan > > > To: haskell-cafe@haskell.org > > From: haskell@list.mightyreason.com > > Date: Tue, 16 Dec 2008 12:34:23 +0000 > > Subject: [Haskell-cafe] Re: MVar and Par .. > > > > Mozhgan Kabiri wrote: > > > Hi .. Hope you are doing well . I've just joined this group. > > > > Hi. > > > > > Recently, I am struggling to do some simple experiment with haskell > > > language about parallelism and wrong answers that we can get while > using > > > a shared variable . > > > > Your goal is still unclear. > > Are you trying to create an example which shows unexpected answers? > > Are you trying to create an example which shows the expected answer? > > > > > I tried to write a simple program, for example calculationg 'n=n+1' few > > > > times.And then I tried to do it in parallel by using 'par' and 'pseq' . > > > > The aim was to get the wrong answer because we have to share a variable > > > > here,and without using 'MVar' function we will get the wrong answer for > > > > the calculation . > > > > MVar is a mutable storage cell. One can use forkIO to create IO threads > which > > race to change MVar, and if this is done badly then you can get > unexpected answers. > > > > One cannot use the pure "par" and "pseq" to launch IO threads, so you > cannot use > > "par" and "pseq" to create race conditions, so one can only get the > expected answer. > > > > > I don't kno w how to write it in parallel in order to get a wrong > answer > > > when we don't use MVar,because we have a shared variable here. I read > > > about MVars as well,but also I don't know how to combine MVar and Par > > > together to get the program to work. > > > > I do not immediately see how MVar and "par" can be sensibly combined at > all. > > > > > I wrote this : > > > > > > module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n > | > > > x <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do > > > putStrLn "starting..." let r = f 10 5 putStrLn (show r) putStrLn > "finished" > > > I want to make to work in parallel by using 'Par'.And also use MVar for > > > > this simple example to work. > > > All of the example about MVar are a little bit complicated and I > > > couldn't figure it that how can I write one,the same ! > > > > > > ; Can any one help me with this ? I want a simple example that I can > feel > > > the need of MVar when I run my program in parallel and while I am using > > > > a shared variable. > > > > > > Regards; Mozhgan > > > > I have run out of time, so I leave this part of your question to others. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ------------------------------ > Explore the seven wonders of the world Learn more! > > _______________________________________________ > 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/20081216/57396264/attachment.htm From lrpalmer at gmail.com Tue Dec 16 07:57:35 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Dec 16 07:50:16 2008 Subject: [Haskell-cafe] Re: MVar and Par .. In-Reply-To: <7ca3f0160812160454s72888e26w8292c43f5b8e194a@mail.gmail.com> References: <4947A04F.6060801@list.mightyreason.com> <7ca3f0160812160454s72888e26w8292c43f5b8e194a@mail.gmail.com> Message-ID: <7ca3f0160812160457o7bbe6d4bxd041729f24159713@mail.gmail.com> On Tue, Dec 16, 2008 at 5:54 AM, Luke Palmer wrote: > Okay, that's a bit clearer. Control.Parallel is not what you want; that is > for parallelizing pure code (and is very nice inside its little domain). > But you want concurrent code: multiple threads that change state at the same > time. That is in Control.Concurrent. > > In particular, the "shared variable" is Data.IORef. > > Simple example from which you should be able to extrapolate. Apologies, this code doesn't compile. Here's the fixed version: import Control.Concurrent import Control.Concurrent.MVar import Data.IORef threadBody var = do x <- readIORef var writeIORef var (x+1) main = do var <- newIORef 0 -- spawn two threads forkIO (threadBody var) forkIO (threadBody var) -- look at the value of the variable x <- readIORef var print x -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/4e1cf11c/attachment.htm From magnus at therning.org Tue Dec 16 08:00:24 2008 From: magnus at therning.org (Magnus Therning) Date: Tue Dec 16 07:53:39 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: References: <4946E378.4030109@therning.org> Message-ID: On Tue, Dec 16, 2008 at 12:14 PM, Lemmih wrote: > You could use a Map or a mutable array. However, this kind of problem > comes up a lot less often than you'd think. Well, I happen to have a problem just like it right now, hence my interest :-) In order to better understand the different options I thought I'd look at solving simpler problems with similar "shape". Thanks for pointing me in the direction of mutable arrays, I haven't explored those before. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From mozhgan_kch at hotmail.com Tue Dec 16 08:18:41 2008 From: mozhgan_kch at hotmail.com (Mozhgan Kabiri) Date: Tue Dec 16 08:11:22 2008 Subject: [Haskell-cafe] Re: MVar and Par .. In-Reply-To: <7ca3f0160812160454s72888e26w8292c43f5b8e194a@mail.gmail.com> References: <4947A04F.6060801@list.mightyreason.com> <7ca3f0160812160454s72888e26w8292c43f5b8e194a@mail.gmail.com> Message-ID: Hi .. Thanks .. But I keep get error when I run the program in order to see the result . It says 'var' is not in the scope. Mozhgan Date: Tue, 16 Dec 2008 05:54:40 -0700 From: lrpalmer@gmail.com To: mozhgan_kch@hotmail.com Subject: Re: [Haskell-cafe] Re: MVar and Par .. CC: haskell@list.mightyreason.com; haskell-cafe@haskell.org Okay, that's a bit clearer. Control.Parallel is not what you want; that is for parallelizing pure code (and is very nice inside its little domain). But you want concurrent code: multiple threads that change state at the same time. That is in Control.Concurrent. In particular, the "shared variable" is Data.IORef. Simple example from which you should be able to extrapolate. import Control.Concurrent import Control.Concurrent.MVar import Data.IORef threadBody = do x <- readIORef var writeIORef var (x+1) main = do var <- newIORef 0 -- spawn two threads forkIO threadBody forkIO threadBody -- look at the value of the variable x <- readIORef var print x You can scatter threadDelay throughout this code to mess with the scheduler and show how a failure could happen. Conversion to MVars should be pretty straightforward. Luke 2008/12/16 Mozhgan Kabiri Hi , Yeah , first I want to get unexpected answer ! And then I want to prove that when I use MVar I will get the write answer.I want to show that when we have a shared variable, we should use MVar.Besides we use for example two processors to do different tasks.But the point is these processors have to share a variable and I want to show it with MVar.But I don't know how to write a simple code to show it while undrestand it. Mozhgan > To: haskell-cafe@haskell.org > From: haskell@list.mightyreason.com > Date: Tue, 16 Dec 2008 12:34:23 +0000 > Subject: [Haskell-cafe] Re: MVar and Par .. > > Mozhgan Kabiri wrote: > > Hi .. Hope you are doing well . I've just joined this group. > > Hi. > > > Recently, I am struggling to do some simple experiment with haskell > > language about parallelism and wrong answers that we can get while using > > a shared variable . > > Your goal is still unclear. > Are you trying to create an example which shows unexpected answers? > Are you trying to create an example which shows the expected answer? > > > I tried to write a simple program, for example calculationg 'n=n+1' few > > times.And then I tried to do it in parallel by using 'par' and 'pseq' . > > The aim was to get the wrong answer because we have to share a variable > > here,and without using 'MVar' function we will get the wrong answer for > > the calculation . > > MVar is a mutable storage cell. One can use forkIO to create IO threads which > race to change MVar, and if this is done badly then you can get unexpected answers. > > One cannot use the pure "par" and "pseq" to launch IO threads, so you cannot use > "par" and "pseq" to create race conditions, so one can only get the expected answer. > > > I don't kno w how to write it in parallel in order to get a wrong answer > > when we don't use MVar,because we have a shared variable here. I read > > about MVars as well,but also I don't know how to combine MVar and Par > > together to get the program to work. > > I do not immediately see how MVar and "par" can be sensibly combined at all. > > > I wrote this : > > > > module Main where f :: Int -> Int -> Int f i n = g 1 i n where g x i n | > > x <= i = g (x+1) i (n+1) | otherwise = n main :: IO () main = do > > putStrLn "starting..." let r = f 10 5 putStrLn (show r) putStrLn "finished" > > I want to make to work in parallel by using 'Par'.And also use MVar for > > this simple example to work. > > All of the example about MVar are a little bit complicated and I > > couldn't figure it that how can I write one,the same ! > > > > ; Can any one help me with this ? I want a simple example that I can feel > > the need of MVar when I run my program in parallel and while I am using > > a shared variable. > > > > Regards; Mozhgan > > I have run out of time, so I leave this part of your question to others. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe Explore the seven wonders of the world Learn more! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/38a19287/attachment.htm From emax at chalmers.se Tue Dec 16 08:47:32 2008 From: emax at chalmers.se (Emil Axelsson) Date: Tue Dec 16 08:40:12 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: References: <4946E378.4030109@therning.org> Message-ID: <4947B174.4020801@chalmers.se> This is actually a perfect case for lazy immutable arrays, if you use a circular program: > import Data.Array > > foo' :: Array Int Int -> Int -> Int > foo' arr 0 = 0 > foo' arr 1 = 1 > foo' arr 2 = 2 > foo' arr n = arr!(n-1) + arr!(n-2) + arr!(n-3) > > foo :: Int -> Int > foo n = arr ! n > where > assocs = [(i, foo' arr i) | i <- [0..n]] > arr = array (0,n) assocs But I haven't checked its performance against your version, so I don't know how good it is. / Emil Magnus Therning skrev: > On Tue, Dec 16, 2008 at 12:14 PM, Lemmih wrote: >> You could use a Map or a mutable array. However, this kind of problem >> comes up a lot less often than you'd think. > > Well, I happen to have a problem just like it right now, hence my > interest :-) In order to better understand the different options I > thought I'd look at solving simpler problems with similar "shape". > > Thanks for pointing me in the direction of mutable arrays, I haven't > explored those before. > > /M > From naur at post11.tele.dk Tue Dec 16 09:00:05 2008 From: naur at post11.tele.dk (Thorkil Naur) Date: Tue Dec 16 08:54:19 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: References: <4946E378.4030109@therning.org> Message-ID: <200812161500.12842.naur@post11.tele.dk> Hello, On Tuesday 16 December 2008 13:19, Felipe Lessa wrote: > 2008/12/16 Magnus Therning : > > That is, where each value depends on _all_ preceding values. AFAIK > > list access is linear, is there a type that is a more suitable state > > for this changed problem? > > > > I realise this particular function can be written using scanl: > [...] > > but I guess it's not always that easy to construct a solution based on scanl. > > > You can always write something like > > > foo :: Int -> Int > > foo = (vals !!) > > where > > vals = map foo' [0..] > > foo' 0 = 0 > > foo' 1 = 1 > > foo' 2 = 2 > > foo' n = sum $ map foo [0..n-1] > > which doesn't prevent you from using whatever recursive case you want. > Note that if your recursive case depends on all preceding values, then > you can't do better than using a linear access data structure like a > list unless you need random access. Another possibility would be: > g n = t!n > where > t = array > (0,max 2 n) > $ (0,0):(1,1):(2,2):[ (i,t!(i-3) + t!(i-2) + t!(i-1)) | i <- [3..n] ] using your original example. As noted in the Haskell 98 report, section 16.1 Array Construction, the array function is non-strict in the values of the association list, making this recurrence possible. > ... Best regards Thorkil From Christian.Maeder at dfki.de Tue Dec 16 10:24:25 2008 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Tue Dec 16 10:17:05 2008 Subject: [Haskell-cafe] Re: GHC 6.10.1 for Solaris i86 In-Reply-To: <21bdabea0812111811h6735d02bk1f57986f403723da@mail.gmail.com> References: <21bdabea0812111811h6735d02bk1f57986f403723da@mail.gmail.com> Message-ID: <4947C829.1000408@dfki.de> Donald Halomoan wrote: > I am waiting for GHC 6.10. 1 binary for Solaris i86. Thanks. You could try mine: http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/pc-solaris/ghcs/ghc-6.10.1-i386-unknown-solaris2.tar.bz2 it needs libedit.so.0 and libncurses.so.5 Cheers Christian From haskell at list.mightyreason.com Tue Dec 16 10:23:05 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Dec 16 10:18:26 2008 Subject: [Haskell-cafe] Re: How to think about this? (profiling) In-Reply-To: <4946E378.4030109@therning.org> References: <4946E378.4030109@therning.org> Message-ID: <4947C7D9.8060000@list.mightyreason.com> Or if you don't want to pay for laziness at all you could build your memo array imperatively (but purely): > import Data.Array.IArray(elems,(!),inRange) > import Data.Array.MArray(newArray_,writeArray,readArray) > import Data.Array.Unboxed(UArray) > import Data.Array.ST(runSTUArray,STUArray) > import Control.Monad(forM_) > import Data.List(zipWith3) > > ackMemoSize :: Int > ackMemoSize = 12; > > ackList :: [Int] > ackList = 0:1:2:zipWith3 (\ i j k -> i+j+k) ackList (tail ackList) (tail (tail ackList)) > > ackMemo :: UArray Int Int > ackMemo = runSTUArray $ do -- the $ works with ghc 6.10, hooray > a <- newArray_ (0,ackMemoSize) > writeArray a 0 0 > writeArray a 1 1 > writeArray a 2 2 > let op i x | i > ackMemoSize = return () > | otherwise = do > writeArray a i x > y <- readArray a (i-3) > op (succ i) $! (2*x-y) -- could use (2*x) intead > op 3 (0+1+2) > return a > > ack :: Int -> Int > ack i | inRange (0,ackMemoSize) i = ackMemo ! i > | otherwise = error "outsize memorized range for ack" > > test = (take (succ ackMemoSize) ackList) == (elems ackMemo) > && (ackList !! ackMemoSize) == (ack ackMemoSize) Which should have very good performance in building ackMemo (the first time it is used). By changing the (2*x-y) to (2*x) I think you get the sum-of-all-previous-entries behavior. Cheers, Chris From eyal.lotem at gmail.com Tue Dec 16 10:26:00 2008 From: eyal.lotem at gmail.com (Eyal Lotem) Date: Tue Dec 16 10:18:41 2008 Subject: [Haskell-cafe] Type wildcards Message-ID: Martin Foster (aka. EvilTerran) suggested an interesting idea, and I decided it was too nice to ignore/be forgotten inside Martin's head... So I'd like to try and suggest it. Type wildcards that allow partially specifying types, e.g: f :: _ -> String f x = show x This will instruct the type-inferrer to "fill out" the wild-card part only (e.g: Show a => a). This feature can be used for a couple of benefits: A. It allows hard-coding part of a type, rather than the all-or-nothing situation we have now (I want to force a single parameter to be more specific, but I'd still prefer to infer the whole type). B. Without scoped type variables, there are currently situations you cannot provide a type signature at all. This may mean that you cannot resolve type ambiguities in some cases, or make types more specific for some purpose. A type wild-card, in addition to scoped type variables, will allow to only specify the part we want. C. Its a nice way to kill the -Wall warnings about missing type declarations, if you want to: f :: _ f = "I am explicitly asking to infer this type, rather than specifying it" Eyal -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/7010e17a/attachment.htm From rjljr2 at yahoo.com Tue Dec 16 10:28:50 2008 From: rjljr2 at yahoo.com (Ronald Legere) Date: Tue Dec 16 10:21:32 2008 Subject: [Haskell-cafe] Re: [Haskell] Missing Documentation References: <132824.25314.qm@web50912.mail.re2.yahoo.com> <404396ef0812160045h370b280cib521488b7a39ccc4@mail.gmail.com> Message-ID: <890911.5634.qm@web50910.mail.re2.yahoo.com> >> This may very well be a FAQ, but I tried to search the archives and could not find a post... >> Anyway, some documentation seems to be missing, which was there before I thought. For example: >> http://www.haskell.org/ghc/docs/latest/html/libraries/haskell98/Random.html >That's a bug, I've reported it here: >http://hackage.haskell.org/trac/ghc/ticket/2886 >> Thanks, and sorry if this lowers the S/N >We usually use haskell@ for annoucements, and haskell-cafe@ for >general discussion/questions etc, so in future these kinds of posts > Neil Thanks... I have been 'away' from Haskell for a while and it is taking me a bit to get re-synced! Anyway, before posting here I also sent an email to Simon Marlow, and he let me know that this bug (or one very similar) was reported for Char in: http://hackage.haskell.org/trac/ghc/ticket/2746 From ndmitchell at gmail.com Tue Dec 16 10:34:17 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Dec 16 10:27:00 2008 Subject: [Haskell-cafe] Re: [Haskell] Missing Documentation In-Reply-To: <890911.5634.qm@web50910.mail.re2.yahoo.com> References: <132824.25314.qm@web50912.mail.re2.yahoo.com> <404396ef0812160045h370b280cib521488b7a39ccc4@mail.gmail.com> <890911.5634.qm@web50910.mail.re2.yahoo.com> Message-ID: <404396ef0812160734i40cb4c18jb0c2e2e24c46540a@mail.gmail.com> Hi Ron, > Thanks... I have been 'away' from Haskell for a while and it is taking me a bit to get re-synced! > > Anyway, before posting here I also sent an email to Simon Marlow, and > he let me know that this bug (or one very similar) was reported for > Char in: > http://hackage.haskell.org/trac/ghc/ticket/2746 I did search the bug tracker before filing my bug report, but found nothing. I guess searching the bug tracker using Google is probably easier... Anyway, I've marked the new bug as a duplicate. Thanks Neil From rmm-haskell at z.odi.ac Tue Dec 16 10:34:24 2008 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Dec 16 10:27:14 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <6702768A-CF89-4110-8990-3112DD2740E2@z.odi.ac> It does require a mathematical mind, but does not require that you understand the mathematical language. If mathematics are the basis of computation, and programming is an implementation of computation, then in many ways programming languages are a (less powerful) equivalent language to the language of mathematics as applied to computation. I've been professionally programming for many years, and did it as a hobby since I was very young. I'm not going to say that I'm some kind of super programmer or anything, but I have had a decent amount of programming experience in a variety of languages. That said, Haskell vexed and threw me off for a couple years before I finally sat down and tried to "pull aside" the curtain of mathematics terms that were (for me) obscuring how to use Haskell. Once I sat down with a ton of examples and just plodded through a bunch of research papers (it seems like all the "fun" features in Haskell are only described in research papers ;-) ) I saw how what I knew from the other programming languages I knew was doable in Haskell and it increased my understanding, where I can now kind-of maybe understand what those papers are talking about by relating it to how the compiler will implement the code. Of course, now that I get it, Haskell is my favorite compiled language hands-down. It was just a much longer steeper learning curve because I had to learn it and the terms used to describe it simultaneously rather than having a leg up on either from knowing other programming languages. Now, don't get me wrong, I don't think that the goal with a language should necessarily be to attract as many people as possible, but don't you feel bad for those poor sots who don't understand how bad off the mainstream of Java, C++, etc is? ;-) Just my 2 cents as a non-math-learned programmer. -Ross On Dec 16, 2008, at 7:12 AM, Malcolm Wallace wrote: > Andrew Coppin wrote: > >> To him, apparently, the current logo says "Haskell is all >> about arcane and obscure mathematical constructs. In fact, we think >> that complicated mathematics is so good that we stuffed our logo >> full >> of it. If you don't like hard math, don't even bother trying to >> learn >> this language." > > I think he got the right idea (kind of). To him, mathematics is > arcane, > but to Haskellers it is the fundamental basis of computation. If > someone is not prepared to invest in learning the foundations of the > subject of Computer Science, then they have no business becoming a > programmer. Would you want someone who disdains mathematics to be > responsible for designing the physical aerodynamics of aircraft? Then > why would you permit them to program the control software that will > fly > it? > > We really must get away from the idea that programming is something > any > old fool should be able to pick up. Programming correct software is > hard, and it requires a mathematical mind. > > Regards, > Malcolm > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From devriese at cs.tcd.ie Tue Dec 16 10:39:54 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Tue Dec 16 10:32:35 2008 Subject: [Haskell-cafe] Type wildcards In-Reply-To: References: Message-ID: <20081216153954.GA30765@netsoc.tcd.ie> Hi, On Tue, Dec 16, 2008 at 05:26:00PM +0200, Eyal Lotem wrote: > Martin Foster (aka. EvilTerran) suggested an interesting idea, and I decided > it was too nice to ignore/be forgotten inside Martin's head... So I'd like > to try and suggest it. > > Type wildcards that allow partially specifying types, e.g: > > f :: _ -> String > f x = show x > > This will instruct the type-inferrer to "fill out" the wild-card part only > (e.g: Show a => a). What you are describing is (an instance of) the "some" operator. For example, see http://research.microsoft.com/en-us/um/people/daan/download/papers/hmf.pdf Section 5.1, "Partial annotations". And yes, I agree, they are useful :) Edsko From haskell at list.mightyreason.com Tue Dec 16 10:44:26 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Dec 16 10:37:18 2008 Subject: [Haskell-cafe] Re: Type wildcards In-Reply-To: References: Message-ID: <4947CCDA.6010405@list.mightyreason.com> You can get pretty far with the same trick oleg mentions at [1]. If you use local type signature then you can do things like this: > {- > ghci infers this type: > *Main> :t f > f :: (Ord a) => Int -> a -> t -> String > -} > f i j x | False = (undefined (i::Int) (isOrd j)) :: String > f i j x = error "not filled in" > > isOrd :: Ord a => a -> () > isOrd = undefined > Cheers, Chris [1] http://okmij.org/ftp/Haskell/types.html#partial-sigs From vanenkj at gmail.com Tue Dec 16 11:26:43 2008 From: vanenkj at gmail.com (John Van Enk) Date: Tue Dec 16 11:20:09 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: hl2.png Type: image/png Size: 26268 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/ec898862/hl2.png From bertram.felgenhauer at googlemail.com Tue Dec 16 11:36:32 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Tue Dec 16 11:30:23 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: <4946E378.4030109@therning.org> References: <4946E378.4030109@therning.org> Message-ID: <20081216163632.GB4206@zombie.inf.tu-dresden.de> Magnus Therning wrote: > This behaviour by Haskell seems to go against my intuition, I'm sure I > just need an update of my intuition ;-) > > I wanted to improve on the following little example code: > > foo :: Int -> Int > foo 0 = 0 > foo 1 = 1 > foo 2 = 2 > foo n = foo (n - 1) + foo (n - 2) + foo (n - 3) Two more ideas: How about -- "loop" keeping the last three elements of the sequence -- O(n) per call, constant memory foo' :: Int -> Int foo' n = go n 0 1 2 where go 0 a _ _ = a go n a b c = go (n - 1) b c (a + b + c) or -- analogue of the folklore fibonacci definition: -- fibs = 0 : 1 : zipWith (+) fibs (tail fibs) foos :: [Int] foos = 0 : 1 : 2 : zipWith3 (\a b c -> a + b + c) foos (tail foos) (tail (tail foos)) [snip] > Then I added a convenience function and called it like this: > > createArray :: Int -> UArray Int Int > createArray n = array (0, n) (zip [0..n] (repeat (-1))) > > main = do > (n:_) <- liftM (map read) getArgs > print $ evalState (foo n) (createArray n) > [snip] > > main = do > (n:_) <- liftM (map read) getArgs > print $ evalState (mapM_ foo [0..n] >> foo n) (createArray n) > > Then I started profiling and found out that the latter version both uses > more memory and makes far more calls to `foo`. That's not what I > expected! (I suspect there's something about laziness I'm missing.) > > Anyway, I ran it with `n=35` and got > > foo n : 202,048 bytes , foo entries 100 > mapM_ foo [0..n] >> foo n : 236,312 , foo entries 135 + 1 The number of function calls is to be expected: to evaluate foo n for the first time, you need to call foo (n-1), foo (n-2) and foo (n-3), making 4 calls per evaluated value. 36*4 = 144 is pretty close to 135. (The "missing" 9 calls correspond to foo 0, foo 1 and foo 2) The difference of 35 can be explained in the same way: the first version makes 35 fewer explicit calls to 'foo'. Bertram From darrinth at gmail.com Tue Dec 16 12:40:27 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Tue Dec 16 12:33:08 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: My $0.02 us: Apologies for ascii art, and hopefully gmail doesn't munge this: ---- ---- \ \ \ \ ------------ \ \ \ \ \ | \ \ \ \ ----------- \ \ \ \ / / / \ -------- / / / \ \ | / / / /\ \ ------- / / / / \ \ ---- ---- ---- -- Darrin From hpacheco at gmail.com Tue Dec 16 13:00:57 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Tue Dec 16 12:53:38 2008 Subject: [Haskell-cafe] Haskell as a religion Message-ID: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> I just found this on the web. Do you like the description of Haskell? It is not that far from true :P http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/07cbf8b9/attachment.htm From igloo at earth.li Tue Dec 16 13:28:59 2008 From: igloo at earth.li (Ian Lynagh) Date: Tue Dec 16 13:21:41 2008 Subject: [Haskell-cafe] haskell compiler never comes back In-Reply-To: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> Message-ID: <20081216182859.GA28411@matrix.chaos.earth.li> Hi Greg, On Mon, Dec 15, 2008 at 12:23:08PM -0800, Greg Meredith wrote: > > The simple-minded and smallish code sample at this > linkcauses the compiler to go off > into never-never land. Any clues would be > greatly appreciated. I've lost track of this thread, but if you still think there's a bug then can you report it in the GHC trac please?: http://hackage.haskell.org/trac/ghc/wiki/ReportABug Please give an example without UndecidableInstances if possible, and the smaller the example is the easier it is for us to look into it. Thanks Ian From lgreg.meredith at biosimilarity.com Tue Dec 16 13:32:59 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Tue Dec 16 13:25:39 2008 Subject: [Haskell-cafe] haskell compiler never comes back In-Reply-To: <20081216182859.GA28411@matrix.chaos.earth.li> References: <5de3f5ca0812151223i66eb2058r5b5d360701fc8439@mail.gmail.com> <20081216182859.GA28411@matrix.chaos.earth.li> Message-ID: <5de3f5ca0812161032v105839d0j8a520ba56ea33b44@mail.gmail.com> Ian, Thanks for your diligence! i upgraded to ghc 6.10.1 and that resolved the issue. i've a working version of the sample at this link . Best wishes, --greg On Tue, Dec 16, 2008 at 10:28 AM, Ian Lynagh wrote: > > Hi Greg, > > On Mon, Dec 15, 2008 at 12:23:08PM -0800, Greg Meredith wrote: > > > > The simple-minded and smallish code sample at this > > linkcauses the compiler to go off > > into never-never land. Any clues would be > > greatly appreciated. > > I've lost track of this thread, but if you still think there's a bug > then can you report it in the GHC trac please?: > http://hackage.haskell.org/trac/ghc/wiki/ReportABug > > Please give an example without UndecidableInstances if possible, and the > smaller the example is the easier it is for us to look into it. > > > Thanks > Ian > > -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/c9e5bc5f/attachment.htm From wren at freegeek.org Tue Dec 16 15:09:20 2008 From: wren at freegeek.org (wren ng thornton) Date: Tue Dec 16 15:02:26 2008 Subject: [Haskell-cafe] How to think about this? (profiling) In-Reply-To: References: <4946E378.4030109@therning.org> Message-ID: <49480AF0.7010202@freegeek.org> Lemmih wrote: > On Tue, Dec 16, 2008 at 1:07 PM, Magnus Therning wrote: > > I understand your solution, but AFAICS it's geared towards limited > > recursion in a sense. What if I want to use memoization to speed up > > something like this > > > > foo :: Int -> Int > > foo 0 = 0 > > foo 1 = 1 > > foo 2 = 2 > > foo n = sum [foo i | i <- [0..n - 1]] > > > > That is, where each value depends on _all_ preceding values. AFAIK > > list access is linear, is there a type that is a more suitable state > > for this changed problem? > > You could use a Map or a mutable array. However, this kind of problem > comes up a lot less often than you'd think. And, that example is also easily memoizable by forward chaining (i.e. accumulators). The reason is because `sum` is such a simple function that you can decompose it as total_{t} = total_{t-1} + x_{t}; and given that x_{t} is defined to be the same as total_{t-1} we have: > foo i = foos !! i > where > foos = let s x = x : (s $! x + x) in 0 : 1 : 2 : s 3 You'd need to come up with an example where you replace `sum` with a function that is a non-decomposable combination of its input values. Lists are beautiful for being decomposable, which is why we have such nice functions as foldr and friends, so anything intuitive based on a list is most likely going to be decomposable as well. Coming up with a variadic function which isn't decomposable is extremely uncommon in practice. -- Live well, ~wren From andrewcoppin at btinternet.com Tue Dec 16 15:14:22 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Dec 16 15:07:05 2008 Subject: [Haskell-cafe] Random language humour Message-ID: <49480C1E.4010904@btinternet.com> http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html Seems pretty accurate, actually... From paul at cogito.org.uk Tue Dec 16 15:19:35 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Tue Dec 16 15:12:34 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> Message-ID: <49480D57.5070706@cogito.org.uk> Hugo Pacheco wrote: > http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html What does it mean, "*If* Programming Languages were religions"? Paul. From mail at justinbogner.com Tue Dec 16 15:22:58 2008 From: mail at justinbogner.com (mail@justinbogner.com) Date: Tue Dec 16 15:15:52 2008 Subject: [Haskell-cafe] Re: Time for a new logo? References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <87abavvpi5.fsf@justinbogner.com> "Darrin Thompson" writes: > ---- ---- > \ \ \ \ ------------ > \ \ \ \ \ | > \ \ \ \ ----------- > \ \ \ \ > / / / \ -------- > / / / \ \ | > / / / /\ \ ------- > / / / / \ \ > ---- ---- ---- +1 From andrewcoppin at btinternet.com Tue Dec 16 15:23:50 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Dec 16 15:16:33 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <49480E56.6000506@btinternet.com> Malcolm Wallace wrote: > Andrew Coppin wrote: > > >> To him, apparently, the current logo says "Haskell is all >> about arcane and obscure mathematical constructs. In fact, we think >> that complicated mathematics is so good that we stuffed our logo full >> of it. If you don't like hard math, don't even bother trying to learn >> this language." >> > > I think he got the right idea (kind of). To him, mathematics is arcane, > but to Haskellers it is the fundamental basis of computation. If > someone is not prepared to invest in learning the foundations of the > subject of Computer Science, then they have no business becoming a > programmer. > > We really must get away from the idea that programming is something any > old fool should be able to pick up. Programming correct software is > hard, and it requires a mathematical mind. > I think the accusation is more that Haskell tries to be cryptic and arcane *on purpose*, just to confuse people. Sure, there are many concepts in Haskell which just aren't found anywhere else. But monads? Catamorphisms? Coroutines? Couldn't we think up some less intimidating terminology? {-# LANGUAGE ExistentialQuantification #-} Hmm, now if this was Perl or something, that would be HiddenTypeVariables or something. Much less fearsom-sounding. But then, I guess that's what you get for a lanuage designed by a committee of university professors. ;-) At any rate, if we're to have a logo, let's not have one which actively *promotes* the notion that Haskell is complex and difficult and that only theoretical physicists need apply... From dons at galois.com Tue Dec 16 15:34:27 2008 From: dons at galois.com (Don Stewart) Date: Tue Dec 16 15:27:05 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <49480D57.5070706@cogito.org.uk> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> Message-ID: <20081216203427.GD32325@scytale.galois.com> paul: > Hugo Pacheco wrote: > >http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html > What does it mean, "*If* Programming Languages were religions"? I think of Haskell more as a revolutionary movement. From andrewcoppin at btinternet.com Tue Dec 16 15:38:53 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Dec 16 15:31:40 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <20081216203427.GD32325@scytale.galois.com> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> Message-ID: <494811DD.5070908@btinternet.com> Don Stewart wrote: > I think of Haskell more as a revolutionary movement LOL! Longest revolution EVER, eh? I mean, how long ago was its dogma first codified? ;-) The thing that saddens me is this: http://prog21.dadgum.com/31.html Basically, Haskell will never be popular, but its coolest ideas will be stolen by everybody else and passed off as their own. :-( From andrewcoppin at btinternet.com Tue Dec 16 15:43:07 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Dec 16 15:35:46 2008 Subject: [Haskell-cafe] Implementing PacMan Message-ID: <494812DB.8060902@btinternet.com> What do we think of this, folks? http://prog21.dadgum.com/23.html (And the rest in the series, obviously.) To me, it seems that this plan would *work*... but it wouldn't be very eligant. You'd have the code to respond to user input and move PacMan in one place, the code for collision detection in other place, the code that decides what to *do* about a collision somewhere else, the code for drawing the animations in yet another place... If you wanted to change one game element, you'd have to make changes scattered all over the place. The whole thing seems messy, non-modular and non-composible to my ears. Thoughts, people? From moonlite at dtek.chalmers.se Fri Dec 12 14:42:32 2008 From: moonlite at dtek.chalmers.se (Mattias Bengtsson) Date: Tue Dec 16 16:00:21 2008 Subject: [Haskell-cafe] Memoization-question In-Reply-To: <20081212144734.GA4206@zombie.inf.tu-dresden.de> References: <1229008692.7839.14.camel@moonlite> <20081212144734.GA4206@zombie.inf.tu-dresden.de> Message-ID: <1229110952.6232.2.camel@moonlite> On Fri, 2008-12-12 at 15:47 +0100, Bertram Felgenhauer wrote: > GHC does "opportunistic CSE", when optimizations are enabled. [...] I see. Thank you! Mattias From paul at cogito.org.uk Tue Dec 16 16:17:39 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Tue Dec 16 16:10:58 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <20081216203427.GD32325@scytale.galois.com> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> Message-ID: <49481AF3.6090205@cogito.org.uk> Don Stewart wrote: > paul: > >> What does it mean, "*If* Programming Languages were religions"? >> > > I think of Haskell more as a revolutionary movement. > > Hmm. Have a look at my submission for the logo contest. Paul. From bjorn.buckwalter at gmail.com Tue Dec 16 16:18:55 2008 From: bjorn.buckwalter at gmail.com (Bjorn Buckwalter) Date: Tue Dec 16 16:11:51 2008 Subject: [Haskell-cafe] Re: Reader monad, implicit parameters, or something else altogether? References: <8b2a1a960808180724k1881b4dfr40e5d1da5128f06e@mail.gmail.com> <20080818225450.luxidshioog04sg0-nwo@webmail.spamcop.net> Message-ID: Richard A. O'Keefe cs.otago.ac.nz> writes: > Just an idiot-level question: so these "constants" are subject > to revision, but *how often*? What is the actual cost of > recompiling and using them *as* constants, compared with the > cost of rereading the stuff every time you run the program and > passing it around? My apologies but I kind of lost track of this thread after the initial helpful replies and didn't follow up diligently on what went only to haskell-cafe (which I don't follow regularly) and not to my inbox. In case you are still curious an example of data that changes frequently is Earth orientation parameters (of which the leap seconds which Andrew elaborated on are one). These include e.g. the difference between UT1 and UTC (UT1-UTC) which is necessary to accurately relate the position and orientation of e.g. a ground based observer to an object in inertial space. UT1-UTC is continuously monitored with new observed an predicted values being published daily. Additional parameters and their update frequencies are listed at [1] and available compiled and with some documentation at [2]. [1] http://www.celestrak.com/SpaceData/EOP-format.asp [2] http://www.celestrak.com/SpaceData/ A piece of software precessing e.g. satellite orbit observations would ideally use the latest Earth orientation parameter data without requiring a recompile for each day. Thanks, Bjorn From jonathanccast at fastmail.fm Tue Dec 16 16:20:41 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Tue Dec 16 16:13:54 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49480E56.6000506@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> Message-ID: <1229462441.17249.6.camel@jcchost> On Tue, 2008-12-16 at 20:23 +0000, Andrew Coppin wrote: > Malcolm Wallace wrote: > > Andrew Coppin wrote: > > > > > >> To him, apparently, the current logo says "Haskell is all > >> about arcane and obscure mathematical constructs. In fact, we think > >> that complicated mathematics is so good that we stuffed our logo full > >> of it. If you don't like hard math, don't even bother trying to learn > >> this language." > >> > > > > I think he got the right idea (kind of). To him, mathematics is arcane, > > but to Haskellers it is the fundamental basis of computation. If > > someone is not prepared to invest in learning the foundations of the > > subject of Computer Science, then they have no business becoming a > > programmer. > > > > We really must get away from the idea that programming is something any > > old fool should be able to pick up. Programming correct software is > > hard, and it requires a mathematical mind. > > > > I think the accusation is more that Haskell tries to be cryptic and > arcane *on purpose*, just to confuse people. > > Sure, there are many concepts in Haskell which just aren't found > anywhere else. But monads? Catamorphisms? Coroutines? Couldn't we think > up some less intimidating terminology? If we thought up that terminology, that would be a legitimate complaint. But we didn't; we're just trying to honor our fore-bearers by using their terminology and crediting them when we use their ideas. > {-# LANGUAGE ExistentialQuantification #-} > > Hmm, now if this was Perl or something, that would be > HiddenTypeVariables or something. Much less fearsom-sounding. No, it's cute. Repulsively so. > But then, I guess that's what you get for a lanuage designed by a > committee of university professors. ;-) > > At any rate, if we're to have a logo, let's not have one which actively > *promotes* the notion that Haskell is complex and difficult and that > only theoretical physicists need apply... I'd like to hold out, again, for the idea that we get a higher-quality community by promoting that notion. jcc From jonathanccast at fastmail.fm Tue Dec 16 16:21:36 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Tue Dec 16 16:14:47 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <494811DD.5070908@btinternet.com> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> Message-ID: <1229462496.17249.8.camel@jcchost> On Tue, 2008-12-16 at 20:38 +0000, Andrew Coppin wrote: > Don Stewart wrote: > > I think of Haskell more as a revolutionary movement > > LOL! Longest revolution EVER, eh? No. Das Kapital publication 1867. Russian Revolution 1917. FTW. jcc From nhn at Cs.Nott.AC.UK Tue Dec 16 16:27:16 2008 From: nhn at Cs.Nott.AC.UK (Henrik Nilsson) Date: Tue Dec 16 16:21:08 2008 Subject: [Haskell-cafe] Implementing PacMan In-Reply-To: <494812DB.8060902@btinternet.com> References: <494812DB.8060902@btinternet.com> Message-ID: <49481D34.4050107@cs.nott.ac.uk> Hi, > What do we think of this, folks? > > http://prog21.dadgum.com/23.html > > (And the rest in the series, obviously.) > > To me, it seems that this plan would *work*... but it wouldn't be very > eligant. You'd have the code to respond to user input and move PacMan > in one place, the code for collision detection in other place, the > code that decides what to *do* about a collision somewhere else, the > code for drawing the animations in yet another place... If you wanted > to change one game element, you'd have to make changes scattered all > over the place. The whole thing seems messy, non-modular and > non-composible to my ears. > > Thoughts, people? Functional Reactive Programming (FRP) tends to, in principle, work pretty well for this kind of application. At least it allows for code that is very modular in many ways, includig when it comes to the game state. See e.g. the paper "The Yampa Arcade" or the Haskell game Frag which uses FRP for the game logic: http://www.haskell.org/haskellwiki/Frag The page you referred to didn't seem to consider FRP? Don't know if FRP would address all of your concerns. But as to collisions, we can observe that this involves two or more entities and is, from the perspective of each entity, something external. Thus I don't think it's unreasonable that code handling collision detection is done "somewhere else", meaning outside the code describing the game entities themselves. As to how to respond to collisions, that can be a great deal trickier, and may involve devising suitable interfaces to allow the proper interaction of a set of object to be computed, e.g. in a physical simulation, the masses and velocities of the involved objects must be known. There was an interesting article about building a "Physics Engine" in Haskell in issue 12 of the monad reader that touched on physical collision detection and response: http://www.haskell.org/sitewiki/images/f/f0/TMR-Issue12.pdf For a game like PacMan, I should think collision response is fairly straightforward, though! Best, /Henrik -- Henrik Nilsson School of Computer Science The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From jeremy at n-heptane.com Tue Dec 16 16:44:30 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue Dec 16 16:37:10 2008 Subject: [Haskell-cafe] excessive usage of CPU by threadDelay in GHCi Message-ID: <87ej0723sx.wl%jeremy@n-heptane.com> Hello, I have the following simple program: import Control.Concurrent main = threadDelay (10^6) >> main If I run it in GHCi it requires 2-5% of my CPU. If i compile it, it takes 0% of my CPU. It does not matter if I compile -O0, -O2, -threaded, it always uses 0% (which is good). Is it expected that threadDelay should be really expensive in GHCi? Am I doing something wrong? Or should I file a bug? Thanks. - jeremy From ok at cs.otago.ac.nz Tue Dec 16 17:14:41 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Dec 16 17:07:31 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> References: <20081214211504.GO27904@scytale.galois.com> <0E3266AB-14D9-4F40-BA1D-39D06435D7D4@lempsink.nl> Message-ID: On 15 Dec 2008, at 2:57 pm, Eelco Lempsink wrote: > > > > By the way, the font used (Kautiva) is not free. That's fine, I wouldn't take it as a gift. It looks horrible. From lrpalmer at gmail.com Tue Dec 16 17:29:51 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Dec 16 17:22:32 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <1229462496.17249.8.camel@jcchost> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <1229462496.17249.8.camel@jcchost> Message-ID: <7ca3f0160812161429s5815c1c8v98cbeb4bf5a089c0@mail.gmail.com> On Tue, Dec 16, 2008 at 2:21 PM, Jonathan Cast wrote: > On Tue, 2008-12-16 at 20:38 +0000, Andrew Coppin wrote: > > Don Stewart wrote: > > > I think of Haskell more as a revolutionary movement > > > > LOL! Longest revolution EVER, eh? > > No. > > Das Kapital publication 1867. > Russian Revolution 1917. At the extreme, one could argue Church's 1936 publication about lambda calculus was our foundation, and since our revolution really hasn't happened yet, we would be winning. But by that argument, the Buddhist revolution is beating us by quite a bit. *dreams of a violent Buddhist revolution* Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/98504a3d/attachment.htm From nbloomf at gmail.com Tue Dec 16 17:31:37 2008 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Tue Dec 16 17:24:22 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <9858b5620812161431v300030fcr579b66f25d998953@mail.gmail.com> On Tue, Dec 16, 2008 at 11:40 AM, Darrin Thompson wrote: > My $0.02 us: > > Apologies for ascii art, and hopefully gmail doesn't munge this: > > ---- ---- > \ \ \ \ ------------ > \ \ \ \ \ | > \ \ \ \ ----------- > \ \ \ \ > / / / \ -------- > / / / \ \ | > / / / /\ \ ------- > / / / / \ \ > ---- ---- ---- > > -- > Darrin I really like this idea. It incorporates two important ideas and is simple enough to look good at different sizes; plus, it doesn't look like the Half-life logo. My biggest concern is that to someone not already familiar with Haskell syntax, it might be confusing. (That may or may not be an actual problem.) Nathan Bloomfield -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/06bf687a/attachment.htm From ok at cs.otago.ac.nz Tue Dec 16 17:32:46 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Dec 16 17:25:36 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <1229343882.4444.5.camel@localhost.localdomain> References: <20081214211504.GO27904@scytale.galois.com> <1229343882.4444.5.camel@localhost.localdomain> Message-ID: <75D3DA7A-3567-4D13-A535-AC1A0ACB4155@cs.otago.ac.nz> On 16 Dec 2008, at 1:24 am, ?lvaro Vilanova Vidal wrote: > One more concept. > > The hybrid lambda/infinity sign looks more like a bra advertisement and the lettering is unpleasant. For one thing, the language is called "Haskell", so a logo should not call it "haskell". (The language cares very much about case, after all.) Admittedly lambda signifies functions to us, but there are probably more people who know what A -> B means than who know what lambda means. Arguably Haskell ? ? ? ? conveys something of the language (we do write f :: a -> b -> c -> d -> e for a multiparameter function) and also suggests something dynamic and forward-looking. Indeed, the multiple arrows even suggest concurrency, which is true. From gwern0 at gmail.com Tue Dec 16 17:45:17 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Dec 16 17:37:56 2008 Subject: [Haskell-cafe] Re: Threads not running under GHC 6.10? In-Reply-To: <49466305.4050009@gmail.com> References: <49466305.4050009@gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Mon, Dec 15, 2008 at 9:00 AM, Simon Marlow wrote: -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklIL3wACgkQvpDo5Pfl1oIqAgCdHruLx+LQ1j7vaoJM3VD2vpNr rG0An0IL9ZXTmwd0bcp0V9clBy6UYeGt =UHCv -----END PGP SIGNATURE----- > This particular example illustrates a bug in 6.10.1 that we've since fixed: > > http://hackage.haskell.org/trac/ghc/ticket/2783 OK, that's good... > However in general you can still write expressions that don't allocate > anything (e.g. nfib 1000), and your watchdog thread won't get a chance to > run unless there's a spare CPU available (+RTS -N2). > > Cheers, > Simon But that's bad. What are my options here? Will this threads-not-running issue be fixed in the next release? Since it worked fine in 6.8 as far as I could tell, that makes me think that it must not be anything completely fundamental and unfixable. -- gwern From patperry at stanford.edu Tue Dec 16 18:11:06 2008 From: patperry at stanford.edu (Patrick Perry) Date: Tue Dec 16 18:03:49 2008 Subject: [Haskell-cafe] How to think about this? (profiling) Message-ID: <96F8D9A4-EC73-45B4-AE14-4764291FA04C@stanford.edu> I agree with everyone else who has said that the better solution is Lemmih's. It is simple, fast, and does not use much memory. On the other hand, here is a more faithful implementation of what you were trying to write. To use mutable arrays, you need to work in either the IO or the ST monad. The advantage of ST is the function "runST", which is roughly equivalent to "unsafePerformIO", but is much safer. I hope this helps, Patrick \begin{code} import Control.Monad import Control.Monad.ST import Data.Array.ST import System.Environment -- | Create an array for storing the results of foo 0 through foo n. -- Initialize foo 0, foo 1, and foo 2, but set all other values to -- 'missing'. newMemo :: Int -> ST s (STUArray s Int Int) newMemo n = do arr <- newArray (0,n) missing :: ST s (STUArray s Int Int) writeArray arr 0 0 writeArray arr 1 1 writeArray arr 2 2 return arr -- | Code to indicate a missing value in the memo array. missing :: Int missing = -1 -- | Compute the value of the function at @i@, using the memo-ed results -- in the array. fooWithMemo :: STUArray s Int Int -> Int -> ST s Int fooWithMemo arr i = do x <- readArray arr i if x /= missing then return x else do r <- liftM3 (\ a b c -> a + b + c) (fooWithMemo arr $ i - 1) (fooWithMemo arr $ i - 2) (fooWithMemo arr $ i - 3) writeArray arr i r return r foo :: Int -> Int foo n = runST $ do arr <- newMemo n fooWithMemo arr n main = do (n:_) <- liftM (map read) getArgs print $ foo n \end{code} From lemming at henning-thielemann.de Tue Dec 16 20:00:12 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Dec 16 19:52:56 2008 Subject: [Haskell-cafe] Time for a new logo? -> Haskell logo as a stamp! In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <916b84820812150738w2476a3f0g539ec462d25b08c1@mail.gmail.com> <20081215170344.GD30616@scytale.galois.com> Message-ID: On Mon, 15 Dec 2008, Henning Thielemann wrote: > On Mon, 15 Dec 2008, Don Stewart wrote: > >> And anyone who does a version, place put it on the wiki. >> It'll be lost if you only post to the list. >> >> I propose we gather submissions and vote on the best for a new logo in >> 2009. > > Whatever logo someone prefers: I have written a program using HPDF which > creates stamps for the German post (see http://www.internetmarke.de/) with > custom images: > http://code.haskell.org/~thielema/internetmarke/ Try it out now: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/internetmarke From tonyhannan2 at gmail.com Tue Dec 16 21:14:08 2008 From: tonyhannan2 at gmail.com (Tony Hannan) Date: Tue Dec 16 21:06:48 2008 Subject: [Haskell-cafe] Yampa vs. Reactive Message-ID: Hello, Can someone describe the advantages and disadvantages of the Yampa library versus the Reactive library for functional reactive programming, or point me to a link. Thanks, Tony P.S. It is hard to google for Yampa and Reactive together because "reactive" as in "function reactive programming" always appears with Yampa -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/3ce0632f/attachment.htm From jeff at nokrev.com Tue Dec 16 21:22:44 2008 From: jeff at nokrev.com (Jeff Wheeler) Date: Tue Dec 16 21:15:25 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <9552CB63-FB8D-40A0-948D-5EA371F856F6@nokrev.com> On Dec 16, 2008, at 17:40:27 GMT, Darrin Thompson wrote: > My $0.02 us: > > Apologies for ascii art, and hopefully gmail doesn't munge this: I love this ASCII-art version. I tried to make a vector version of it in Photoshop, and I came up with this [1]. Any critiques/suggestions? I'm thinking about a second version that more obviously defines the second '>' with color from the bottom-right part of the lambda. Jeff Wheeler [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081216/70bbac99/attachment.htm From jeff at nokrev.com Tue Dec 16 21:47:04 2008 From: jeff at nokrev.com (Jeff Wheeler) Date: Tue Dec 16 21:42:43 2008 Subject: [Haskell-cafe] Re: Time for a new logo? References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: Darrin Thompson gmail.com> writes: > My $0.02 us: > > Apologies for ascii art, and hopefully gmail doesn't munge this: I love this ASCII-art version. I tried to make a vector version of it in Photoshop, and I came up with this [1] and [2]. Any critiques/suggestions? I'm thinking about a second version that more obviously defines the second '>' with color from the bottom-right part of the lambda. Jeff Wheeler [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png From porges at porg.es Tue Dec 16 16:04:41 2008 From: porges at porg.es (George Pollard) Date: Tue Dec 16 23:11:07 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <1229461481.16627.4.camel@porges-laptop> On Tue, 2008-12-16 at 12:40 -0500, Darrin Thompson wrote: > My $0.02 us: > > Apologies for ascii art, and hopefully gmail doesn't munge this: > > ---- ---- > \ \ \ \ ------------ > \ \ \ \ \ | > \ \ \ \ ----------- > \ \ \ \ > / / / \ -------- > / / / \ \ | > / / / /\ \ ------- > / / / / \ \ > ---- ---- ---- --- -------- / / / ____ \ / / / / \ \ / / --- / / / / / / \ \ \ \ \ \ --- \ \ \ \ \ \____/ / \ \ \ / --- -------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/041ee7b6/attachment.bin From porges at porg.es Tue Dec 16 23:21:36 2008 From: porges at porg.es (George Pollard) Date: Tue Dec 16 23:14:31 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <1229487696.16627.5.camel@porges-laptop> On Wed, 2008-12-17 at 02:47 +0000, Jeff Wheeler wrote: > Darrin Thompson gmail.com> writes: > > > My $0.02 us: > > > > Apologies for ascii art, and hopefully gmail doesn't munge this: > > I love this ASCII-art version. I tried to make a vector version of it in > Photoshop, and I came up with this [1] > and [2]. > > Any critiques/suggestions? I'm thinking about a second version that more > obviously defines the second '>' with color from the bottom-right part of the > lambda. > > Jeff Wheeler > > [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png > [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png I like the first version better. :) I'd suggest making the lambda/arrow a bit straighter and beefing up the size of the equals in relation to the rest of the symbol :) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/953a27cd/attachment.bin From jeff at nokrev.com Tue Dec 16 23:25:15 2008 From: jeff at nokrev.com (Jeff Wheeler) Date: Tue Dec 16 23:17:55 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: On Dec 16, 2008, at 10:08 PM, Ryan Grant wrote: > nice. > the first is better. > in the second, i don't even see the lambda. Thanks the feedback. I just uploaded a new version [1] that is icon- sized, although the font used is Helvetica Neue, which is non-free. I have no free fonts on my Mac, unfortunately, so it'll stay for the moment. Jeff Wheeler [1] http://media.nokrev.com/junk/haskell-logos/logo4.png From atomb at galois.com Wed Dec 17 00:39:58 2008 From: atomb at galois.com (Aaron Tomb) Date: Wed Dec 17 00:32:39 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081215170344.GD30616@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> <916b84820812150738w2476a3f0g539ec462d25b08c1@mail.gmail.com> <20081215170344.GD30616@scytale.galois.com> Message-ID: On Dec 15, 2008, at 9:03 AM, Don Stewart wrote: > And anyone who does a version, place put it on the wiki. > It'll be lost if you only post to the list. > > I propose we gather submissions and vote on the best for a new logo in > 2009. I'm a big fan of those posted by FalconNL. I showed the whole page to a professional graphic designer and brand strategist, and she thought that the ">> Haskell" ones were the best of the complete designs, by far, from a design standpoint. I'm not sure which of the three I like best, though. She also really liked the recent symbol inspired by Darrin Thompson's ASCII art. Some variant of FalconNL's original designs with that symbol in place of the ">>" might look nice. The symbol could also be used on its own, which is a plus. Finally, she much preferred Officina Sans over Fonce Sans. It's sad that there are so few good free fonts to choose from, but I'd say it's better to go for the one that looks good. It can be embedded into a vector graphic. Aaron From mail at justinbogner.com Wed Dec 17 02:32:35 2008 From: mail at justinbogner.com (mail@justinbogner.com) Date: Wed Dec 17 02:25:27 2008 Subject: [Haskell-cafe] Re: Time for a new logo? References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <1229487696.16627.5.camel@porges-laptop> Message-ID: <871vw7uui4.fsf@justinbogner.com> George Pollard writes: > On Wed, 2008-12-17 at 02:47 +0000, Jeff Wheeler wrote: >> I love this ASCII-art version. I tried to make a vector version of it in >> Photoshop, and I came up with this [1] >> and [2]. >> >> Any critiques/suggestions? I'm thinking about a second version that more >> obviously defines the second '>' with color from the bottom-right part of the >> lambda. >> >> Jeff Wheeler >> >> [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png >> [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png > > I like the first version better. :) I'd suggest making the lambda/arrow > a bit straighter and beefing up the size of the equals in relation to > the rest of the symbol :) I also like the first better. If the equals was ever so slightly wider, it would be absolutely perfect. From tom.davie at gmail.com Wed Dec 17 03:01:37 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Dec 17 02:54:18 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: References: Message-ID: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> On 17 Dec 2008, at 03:14, Tony Hannan wrote: > Hello, > > Can someone describe the advantages and disadvantages of the Yampa > library versus the Reactive library for functional reactive > programming, or point me to a link. > > Thanks, > Tony > > P.S. It is hard to google for Yampa and Reactive together because > "reactive" as in "function reactive programming" always appears with > Yampa Advantages of Yampa: ? Just at the moment, slightly more polished. ? (maybe) harder to introduce space/time leaks. Advantages of Reactive: ? More functional programming like -- doesn't require you to use arrows everywhere, and supports a nice applicative style. ? In very active development. ? Active community. Hope that helps -- my personal preference is that Reactive is the one I'd use for any FRP project at the moment. Bob From tom.davie at gmail.com Wed Dec 17 03:10:55 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Dec 17 03:03:34 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> On 16 Dec 2008, at 18:40, Darrin Thompson wrote: > ---- ---- > \ \ \ \ ------------ > \ \ \ \ \ | > \ \ \ \ ----------- > \ \ \ \ > / / / \ -------- > / / / \ \ | > / / / /\ \ ------- > / / / / \ \ > ---- ---- ---- Oh please no, please don't let the logo be something that says "Haskell, it's all about monads". Bob From ryani.spam at gmail.com Wed Dec 17 03:13:32 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Dec 17 03:06:11 2008 Subject: [Haskell-cafe] Implementing PacMan In-Reply-To: <494812DB.8060902@btinternet.com> References: <494812DB.8060902@btinternet.com> Message-ID: <2f9b2d30812170013q83f8e9bp4927e0caa598025a@mail.gmail.com> In the last "episode" you talk about an entity's update being a function like: > input_state -> (output_state, [event]) for some suitably defined types of input state, output state, and event. Connecting together functions with types like this is exactly what Reactive does well. You have an event stream representing the behavior of the user during the course of the game, and you use that to construct other values representing the *behavior* of the game. The key difference is that instead of the game's behavior being a set of functions from input to output, it is functions from one behavior to another, eventually culminating in something like > -- "user input", "clock tick"; output a new display list at each clock tick > game :: Event UserInput -> Event () -> Reactive [RenderCommand] In fact, I think your analysis in the first message is somewhat right on; this exercise is somewhat like "writing a novel without using the letter 'e'". The benefits you get from a pure language are not necessarily "lack of effects", but rather, "explicitly mentioning where effects happen". That said, I'm curious where you are going with it. I'd love to see the game running & take a look at your code! -- ryan On Tue, Dec 16, 2008 at 12:43 PM, Andrew Coppin wrote: > What do we think of this, folks? > > http://prog21.dadgum.com/23.html > > (And the rest in the series, obviously.) > > To me, it seems that this plan would *work*... but it wouldn't be very > eligant. You'd have the code to respond to user input and move PacMan in one > place, the code for collision detection in other place, the code that > decides what to *do* about a collision somewhere else, the code for drawing > the animations in yet another place... If you wanted to change one game > element, you'd have to make changes scattered all over the place. The whole > thing seems messy, non-modular and non-composible to my ears. > > Thoughts, people? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wqeqweuqy at hotmail.com Wed Dec 17 03:15:58 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Wed Dec 17 03:06:53 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <871vw7uui4.fsf@justinbogner.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <1229487696.16627.5.camel@porges-laptop> <871vw7uui4.fsf@justinbogner.com> Message-ID: mail@justinbogner.com wrote: > George Pollard writes: >> On Wed, 2008-12-17 at 02:47 +0000, Jeff Wheeler wrote: >>> I love this ASCII-art version. I tried to make a vector version of it in >>> Photoshop, and I came up with this [1] >>> and [2]. >>> >>> Any critiques/suggestions? I'm thinking about a second version that more >>> obviously defines the second '>' with color from the bottom-right part of the >>> lambda. >>> >>> Jeff Wheeler >>> >>> [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png >>> [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png >> I like the first version better. :) I'd suggest making the lambda/arrow >> a bit straighter and beefing up the size of the equals in relation to >> the rest of the symbol :) > > I also like the first better. If the equals was ever so slightly wider, > it would be absolutely perfect. The first is real nice. From ryani.spam at gmail.com Wed Dec 17 03:14:47 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Dec 17 03:07:26 2008 Subject: [Haskell-cafe] Implementing PacMan In-Reply-To: <2f9b2d30812170013q83f8e9bp4927e0caa598025a@mail.gmail.com> References: <494812DB.8060902@btinternet.com> <2f9b2d30812170013q83f8e9bp4927e0caa598025a@mail.gmail.com> Message-ID: <2f9b2d30812170014t62e011a7h4a1dca777799ad63@mail.gmail.com> Oops, misread a bit. I thought this was your series of posts, Andrew! But other than that, my points stand :) -- ryan On Wed, Dec 17, 2008 at 12:13 AM, Ryan Ingram wrote: > In the last "episode" you talk about an entity's update being a function like: > >> input_state -> (output_state, [event]) > > for some suitably defined types of input state, output state, and event. > > Connecting together functions with types like this is exactly what > Reactive does well. You have an event stream representing the > behavior of the user during the course of the game, and you use that > to construct other values representing the *behavior* of the game. > The key difference is that instead of the game's behavior being a set > of functions from input to output, it is functions from one behavior > to another, eventually culminating in something like > >> -- "user input", "clock tick"; output a new display list at each clock tick >> game :: Event UserInput -> Event () -> Reactive [RenderCommand] > > In fact, I think your analysis in the first message is somewhat right > on; this exercise is somewhat like "writing a novel without using the > letter 'e'". The benefits you get from a pure language are not > necessarily "lack of effects", but rather, "explicitly mentioning > where effects happen". > > That said, I'm curious where you are going with it. I'd love to see > the game running & take a look at your code! > > -- ryan > > On Tue, Dec 16, 2008 at 12:43 PM, Andrew Coppin > wrote: >> What do we think of this, folks? >> >> http://prog21.dadgum.com/23.html >> >> (And the rest in the series, obviously.) >> >> To me, it seems that this plan would *work*... but it wouldn't be very >> eligant. You'd have the code to respond to user input and move PacMan in one >> place, the code for collision detection in other place, the code that >> decides what to *do* about a collision somewhere else, the code for drawing >> the animations in yet another place... If you wanted to change one game >> element, you'd have to make changes scattered all over the place. The whole >> thing seems messy, non-modular and non-composible to my ears. >> >> Thoughts, people? >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From noteed at gmail.com Wed Dec 17 03:17:39 2008 From: noteed at gmail.com (minh thu) Date: Wed Dec 17 03:10:16 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <1229487696.16627.5.camel@porges-laptop> <871vw7uui4.fsf@justinbogner.com> Message-ID: <40a414c20812170017j20421985g54e0d1418e9a82b5@mail.gmail.com> 2008/12/17 Neal Alexander : > mail@justinbogner.com wrote: >> >> George Pollard writes: >>> >>> On Wed, 2008-12-17 at 02:47 +0000, Jeff Wheeler wrote: >>>> >>>> I love this ASCII-art version. I tried to make a vector version of it in >>>> Photoshop, and I came up with this [1] and [2]. >>>> >>>> Any critiques/suggestions? I'm thinking about a second version that more >>>> obviously defines the second '>' with color from the bottom-right part of >>>> the lambda. >>>> >>>> Jeff Wheeler >>>> >>>> [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png >>>> [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png >>> >>> I like the first version better. :) I'd suggest making the lambda/arrow >>> a bit straighter and beefing up the size of the equals in relation to >>> the rest of the symbol :) >> >> I also like the first better. If the equals was ever so slightly wider, >> it would be absolutely perfect. > > The first is real nice. It has a military feeling I don't like... Cheers, Thu From lrpalmer at gmail.com Wed Dec 17 03:26:53 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Dec 17 03:19:31 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> Message-ID: <7ca3f0160812170026v1146d80ag5e1e38391836f5ce@mail.gmail.com> On Wed, Dec 17, 2008 at 1:10 AM, Thomas Davie wrote: > > On 16 Dec 2008, at 18:40, Darrin Thompson wrote: > > ---- ---- >> \ \ \ \ ------------ >> \ \ \ \ \ | >> \ \ \ \ ----------- >> \ \ \ \ >> / / / \ -------- >> / / / \ \ | >> / / / /\ \ ------- >> / / / / \ \ >> ---- ---- ---- >> > > Oh please no, please don't let the logo be something that says "Haskell, > it's all about monads". But it's a very pretty logo. And the idea of "computation abstractions", Applicatives and Monads in particular, are a pretty big part of Haskell as a language and as a culture. Haskell, it's not exactly *not* about monads. IOW: ?About(Haskell, Monads) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/0368627a/attachment.htm From tom.davie at gmail.com Wed Dec 17 03:50:36 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Dec 17 03:43:16 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <7ca3f0160812170026v1146d80ag5e1e38391836f5ce@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <7ca3f0160812170026v1146d80ag5e1e38391836f5ce@mail.gmail.com> Message-ID: <1EF110ED-81C9-46FC-B715-F561006A4619@gmail.com> On 17 Dec 2008, at 09:26, Luke Palmer wrote: > On Wed, Dec 17, 2008 at 1:10 AM, Thomas Davie > wrote: > > On 16 Dec 2008, at 18:40, Darrin Thompson wrote: > > ---- ---- > \ \ \ \ ------------ > \ \ \ \ \ | > \ \ \ \ ----------- > \ \ \ \ > / / / \ -------- > / / / \ \ | > / / / /\ \ ------- > / / / / \ \ > ---- ---- ---- > > Oh please no, please don't let the logo be something that says > "Haskell, it's all about monads". > > But it's a very pretty logo. And the idea of "computation > abstractions", Applicatives and Monads in particular, are a pretty > big part of Haskell as a language and as a culture. Haskell, it's > not exactly not about monads. No, I agree, but there's already a large body of literature that implies that Haskell is pretty much only about monads, and I'd hate to see the logo go the same way. Though I do take your point about abstractions being a major part of the language. Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/c063443f/attachment.htm From gianfranco.alongi at gmail.com Wed Dec 17 04:05:55 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Wed Dec 17 03:58:56 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <1EF110ED-81C9-46FC-B715-F561006A4619@gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <7ca3f0160812170026v1146d80ag5e1e38391836f5ce@mail.gmail.com> <1EF110ED-81C9-46FC-B715-F561006A4619@gmail.com> Message-ID: I agree on what some people say; I see no point in trying to advertise "elitism". Let's avoid the same mistake as the linux community made; soon we'll have an internal flame war about which monad is the best (linux distribution flame-wars analog), arguing who's the most 31337 haxxor and so on. In my opinion, true elegance comes from being really good at something without pushing it in the face of others. Let the log say "haskell - it's elegant" without trying to be posh. /Gf 2008/12/17 Thomas Davie : > > On 17 Dec 2008, at 09:26, Luke Palmer wrote: > > On Wed, Dec 17, 2008 at 1:10 AM, Thomas Davie wrote: >> >> On 16 Dec 2008, at 18:40, Darrin Thompson wrote: >> >>> ---- ---- >>> \ \ \ \ ------------ >>> \ \ \ \ \ | >>> \ \ \ \ ----------- >>> \ \ \ \ >>> / / / \ -------- >>> / / / \ \ | >>> / / / /\ \ ------- >>> / / / / \ \ >>> ---- ---- ---- >> >> Oh please no, please don't let the logo be something that says "Haskell, >> it's all about monads". > > But it's a very pretty logo. And the idea of "computation abstractions", > Applicatives and Monads in particular, are a pretty big part of Haskell as a > language and as a culture. Haskell, it's not exactly not about monads. > > No, I agree, but there's already a large body of literature that implies > that Haskell is pretty much only about monads, and I'd hate to see the logo > go the same way. Though I do take your point about abstractions being a > major part of the language. > Bob > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Patience is the last resort for those unable to take action From porges at porg.es Wed Dec 17 04:02:27 2008 From: porges at porg.es (George Pollard) Date: Wed Dec 17 04:03:54 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <40a414c20812170017j20421985g54e0d1418e9a82b5@mail.gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <1229487696.16627.5.camel@porges-laptop> <871vw7uui4.fsf@justinbogner.com> <40a414c20812170017j20421985g54e0d1418e9a82b5@mail.gmail.com> Message-ID: <1229504547.21467.10.camel@porges-laptop> > It has a military feeling I don't like... Might look cuddlier with slightly rounded edges. That's what all the cool kids[1] are doing anyway ;) [1]: http://www.python.org/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/a2bbaf71/attachment.bin From valery.vv at gmail.com Wed Dec 17 04:46:55 2008 From: valery.vv at gmail.com (Valery V. Vorotyntsev) Date: Wed Dec 17 04:39:41 2008 Subject: [Haskell-cafe] Fwd: cabal-install sends invalid proxy password Message-ID: Hello, > I was surprised to discover that `cabal-install' -- a popular utility > for installing Hackage packages -- cannot work with HTTP proxies. > Despite all the necessary code linked in. > > `cabal update' command returns HTTP 407 (Proxy Authentication Required) > error. The problem is explained below and patches follow. See http://article.gmane.org/gmane.comp.lang.haskell.libraries/10420 No response so far. (I start to suspect that there is just one "proxied haskeller" subscribed to `libraries' and `cabal-dev' lists:) -- vvv From regis.saint-paul at create-net.org Wed Dec 17 05:39:05 2008 From: regis.saint-paul at create-net.org (Regis Saint-Paul) Date: Wed Dec 17 05:31:49 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <1229487696.16627.5.camel@porges-laptop><871vw7uui4.fsf@justinbogner.com> Message-ID: <3275AD74D7384CF186811B4D1BBCC3E8@createnet.org> > >>> > >>> Any critiques/suggestions? I'm thinking about a second version that > more > >>> obviously defines the second '>' with color from the bottom-right part > of the > >>> lambda. > >>> > >>> Jeff Wheeler > >>> > >>> [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png > >>> [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png > >> I like the first version better. :) I'd suggest making the lambda/arrow > >> a bit straighter and beefing up the size of the equals in relation to > >> the rest of the symbol :) > > > > I also like the first better. If the equals was ever so slightly wider, > > it would be absolutely perfect. > > The first is real nice. > The [1] is really nice and I would love to see other variations with the wider equal and a bit more rounded edges as was proposed by others. Also the long bar of the lambda may be slightly rounded (as an integral sign), maybe just at the bottom part to avoid disturbing the >>. That would make the logo less military too. As an answer to the critics that referring to the monad would be elitist, I think this it is a non-issue since someone unfamiliar with Haskell would judge the logo purely on its graphical appeal. For me, the criteria of a good logo are: * Simplicity * Graphically pleasant * Do not degrade too much if printed in black and white vs. color or when resized to icon size. The fact it can be rendered in ascii-art is even better. The relation to the topic is quiet optional (hence all the "cute-animal-based" logo). It is however welcomed when it doesn't hurt the design (as in [1]). By comparison, the current logo performs very badly on all these criteria. Cheers, -Regis Saint-Paul From aneumann at inf.fu-berlin.de Wed Dec 17 05:44:14 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Wed Dec 17 05:39:04 2008 Subject: [Haskell-cafe] Trouble with interact in ghci Message-ID: <7B724789-0B67-4A49-9BC9-3E0049C2B946@inf.fu-berlin.de> Hi, I have a strange problem with "interact" on OS X (ghc 6.10.1). It seems to garble stdin. I have some code here http://hpaste.org/13135#a2 , for testing purpose: *Main> main 1 > 1.0 2 > 1.5 3 > 2.0 *Main> setNonBlockingFD: invalid argument (Bad file descriptor) 11:40:45 ~/Desktop> (I hit ctrl-D) *Main> main 1 > 1.0 2 > 1.5 3 > 2.0 ^CInterrupted. *Main> main *** Exception: : hGetContents: illegal operation (handle is closed) *Main> Someone on #haskell suspected my editline to be the culprit. Does anyone of you know what I can do about this problem? Greetings, Adrian -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/07c70180/PGP.bin From ketil at malde.org Wed Dec 17 05:48:30 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Dec 17 05:41:10 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: (Gianfranco Alongi's message of "Wed\, 17 Dec 2008 10\:05\:55 +0100") References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <7ca3f0160812170026v1146d80ag5e1e38391836f5ce@mail.gmail.com> <1EF110ED-81C9-46FC-B715-F561006A4619@gmail.com> Message-ID: <878wqf9iwx.fsf@malde.org> "Gianfranco Alongi" writes: > I agree on what some people say; I see no point in trying to advertise > "elitism". For this reason, my favorite subtitle is "pure . lazy . fun". Nice and friendly, with some doulbe meanings for the cognoscenti. (I'm sorry, but I can't bring myself to add "simple" in there with a straight face.) Is it an option to add a \tau to the \lambda? Especially if we go for the lambda in a circle theme - to differentiate from Half-life, Scheme, and other kids' stuff :-) -k -- If I haven't seen further, it is by standing in the footprints of giants From gianfranco.alongi at gmail.com Wed Dec 17 06:12:29 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Wed Dec 17 06:05:10 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <878wqf9iwx.fsf@malde.org> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <7ca3f0160812170026v1146d80ag5e1e38391836f5ce@mail.gmail.com> <1EF110ED-81C9-46FC-B715-F561006A4619@gmail.com> <878wqf9iwx.fsf@malde.org> Message-ID: I must agree, the proposal " pure . lazy . fun" is quite funny and informative at the same time. It will hopefully also supply people with something to laugh about when they have learned enough. :) While being true, it's also subtle. /Gf On Wed, Dec 17, 2008 at 11:48 AM, Ketil Malde wrote: > "Gianfranco Alongi" writes: > >> I agree on what some people say; I see no point in trying to advertise >> "elitism". > > For this reason, my favorite subtitle is "pure . lazy . fun". Nice > and friendly, with some doulbe meanings for the cognoscenti. (I'm > sorry, but I can't bring myself to add "simple" in there with a > straight face.) > > Is it an option to add a \tau to the \lambda? Especially if we go for > the lambda in a circle theme - to differentiate from Half-life, > Scheme, and other kids' stuff :-) > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > -- Patience is the last resort for those unable to take action From andres at cs.uu.nl Wed Dec 17 07:10:12 2008 From: andres at cs.uu.nl (Andres Loeh) Date: Wed Dec 17 07:02:51 2008 Subject: [Haskell-cafe] Type wildcards In-Reply-To: References: Message-ID: <20081217121012.GA4749@cs.uu.nl> > Type wildcards that allow partially specifying types, e.g: > > f :: _ -> String > f x = show x > > This will instruct the type-inferrer to "fill out" the wild-card part only > (e.g: Show a => a). Also see http://hackage.haskell.org/trac/haskell-prime/wiki/PartialTypeAnnotations Cheers, Andres -- Andres Loeh, Universiteit Utrecht mailto:andres@cs.uu.nl mailto:mail@andres-loeh.de http://www.andres-loeh.de From marlowsd at gmail.com Wed Dec 17 08:05:48 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Dec 17 07:58:30 2008 Subject: [Haskell-cafe] Re: Threads not running under GHC 6.10? In-Reply-To: References: <49466305.4050009@gmail.com> Message-ID: <4948F92C.4070109@gmail.com> Gwern Branwen wrote: > On Mon, Dec 15, 2008 at 9:00 AM, Simon Marlow wrote: >> This particular example illustrates a bug in 6.10.1 that we've since fixed: >> >> http://hackage.haskell.org/trac/ghc/ticket/2783 > > OK, that's good... > >> However in general you can still write expressions that don't allocate >> anything (e.g. nfib 1000), and your watchdog thread won't get a chance to >> run unless there's a spare CPU available (+RTS -N2). >> >> Cheers, >> Simon > > But that's bad. What are my options here? Will this > threads-not-running issue be fixed in the next release? Since it > worked fine in 6.8 as far as I could tell, that makes me think that it > must not be anything completely fundamental and unfixable. I'm afraid the underlying problem is one that GHC has always had - that we can't preempt threads that aren't allocating. It's not easily fixable, we would have to inject dummy heap checks into every non-allocating loop, which would seriously hurt performance for those tight loops. In general you can't rely on being able to kill a thread; however, this only applies to compiled code, interpreted code should always be preemptable, even if it isn't allocating. Cheers, Simon From bulat.ziganshin at gmail.com Wed Dec 17 08:19:18 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Dec 17 08:15:36 2008 Subject: [Haskell-cafe] Re: Threads not running under GHC 6.10? In-Reply-To: <4948F92C.4070109@gmail.com> References: <49466305.4050009@gmail.com> <4948F92C.4070109@gmail.com> Message-ID: <1376688616.20081217161918@gmail.com> Hello Simon, Wednesday, December 17, 2008, 4:05:48 PM, you wrote: > I'm afraid the underlying problem is one that GHC has always had - that we > can't preempt threads that aren't allocating. It's not easily fixable, we > would have to inject dummy heap checks into every non-allocating loop, > which would seriously hurt performance for those tight loops. just technical note - if we unroll such loops and insert one check per 10 repetitions, it may be ok. although conditional execution may be a problem for such solution -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From darrinth at gmail.com Wed Dec 17 08:42:33 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Wed Dec 17 08:35:09 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: On Tue, Dec 16, 2008 at 9:47 PM, Jeff Wheeler wrote: > [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png > [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png > > Oops, I meant to post on list. If you play with the angles and vary the stroke thicknesses you'll probably get a friendlier look, vs. the military/airline look these have now. The first '>' doesn't have to be the same thickness as the lambda. Just another $0.02 us. Thanks for running with it. Those look like I imagined. What I like about the design is anybody can draw it in 5 strokes and it's unmistakably what it is. Sharpie, pencil, even spray paint all work. You could make your own hat or t-shirt and wear it to an important event, or a wedding. You could tag a rival cube farm wall to declare some kind of office war. X monad could have a variant of this logo too. >X= (That's how I originally thought of it, just was too lazy to post it anywhere. Sorry about that.) -- Darrin From mithrandi at mithrandi.net Wed Dec 17 08:57:40 2008 From: mithrandi at mithrandi.net (Tristan Seligmann) Date: Wed Dec 17 08:50:19 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> Message-ID: <20081217135740.GA10904@mithrandi.net> * Thomas Davie [2008-12-17 09:10:55 +0100]: > Oh please no, please don't let the logo be something that says "Haskell, > it's all about monads". I don't see anyone complaining about the python logo being something that says "Python, it's all about snakes" (Python is named after Monty Python). I really don't think that including a visual pun on the (>>=) operator translates to "Haskell, it's all about monads"; you're only likely to recognise the pun after you already know about monads anyway. -- mithrandi, i Ainil en-Balandor, a faer Ambar -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/242d788d/attachment.bin From mithrandi at mithrandi.net Wed Dec 17 09:01:37 2008 From: mithrandi at mithrandi.net (Tristan Seligmann) Date: Wed Dec 17 08:54:16 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49480E56.6000506@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> Message-ID: <20081217140137.GB10904@mithrandi.net> * Andrew Coppin [2008-12-16 20:23:50 +0000]: > I think the accusation is more that Haskell tries to be cryptic and > arcane *on purpose*, just to confuse people. > > Sure, there are many concepts in Haskell which just aren't found > anywhere else. But monads? Catamorphisms? Coroutines? Couldn't we think > up some less intimidating terminology? The problem is that "less intimidating" terminology generally seems to mean inaccurate or misleading terminology. They aren't concepts that aren't found anywhere else, they're concepts that *are* found elsewhere (category theory, among other places), that's why they have those names. (Also, "coroutines"? Seriously? That's hardly an obscure term in programming circles.) > {-# LANGUAGE ExistentialQuantification #-} > > Hmm, now if this was Perl or something, that would be > HiddenTypeVariables or something. Much less fearsom-sounding. Also much less informative, and less accurate. The fact that Haskell embraces its mathematical basis instead of trying to completely obfuscate it away is not a bad thing, in my opinion. > But then, I guess that's what you get for a lanuage designed by a > committee of university professors. ;-) > > At any rate, if we're to have a logo, let's not have one which actively > *promotes* the notion that Haskell is complex and difficult and that > only theoretical physicists need apply... I think you're reading way too much into a logo. -- mithrandi, i Ainil en-Balandor, a faer Ambar -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/6edda01b/attachment.bin From 666wman at gmail.com Wed Dec 17 09:02:40 2008 From: 666wman at gmail.com (wman) Date: Wed Dec 17 08:55:17 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081217135740.GA10904@mithrandi.net> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <20081217135740.GA10904@mithrandi.net> Message-ID: 2008/12/17 Tristan Seligmann > I really don't think that including a visual pun on the (>>=) > operator translates to "Haskell, it's all about monads"; you're only > likely to recognise the pun after you already know about monads anyway. > True, true, and who cares about folks afraid of unknown operators which might do wonderfull stuff ;-))) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/9bd0b124/attachment.htm From gianfranco.alongi at gmail.com Wed Dec 17 09:14:25 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Wed Dec 17 09:08:37 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <20081217135740.GA10904@mithrandi.net> Message-ID: 2008/12/17 wman <666wman@gmail.com>: > 2008/12/17 Tristan Seligmann >> >> I really don't think that including a visual pun on the (>>=) >> operator translates to "Haskell, it's all about monads"; you're only >> likely to recognise the pun after you already know about monads anyway. > > True, true, and who cares about folks afraid of unknown operators which > might do wonderfull stuff ;-))) > That's the kind of mentality I am talking about. The "we are better than you" mentality, should stay with the Java and .NET people. If you have this urge of feeling superior and believe haskell-hacking is some kind of achievement..... . Haskell is a tool like any other, it's the ideas you manifest by it that are important. And of course the way you do it. The logo should be attractive; fire sparks of curiosity, represent what haskell is, capture the essence of haskell. Ps: This is no flame, I am making a point. If you feel this is a flame; then I must apologize for the harsh tone. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Patience is the last resort for those unable to take action From nhn at Cs.Nott.AC.UK Wed Dec 17 09:29:05 2008 From: nhn at Cs.Nott.AC.UK (Henrik Nilsson) Date: Wed Dec 17 09:23:45 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> Message-ID: <49490CB1.8060405@cs.nott.ac.uk> Thomas Davie wrote: > Advantages of Yampa: > ? Just at the moment, slightly more polished. > ? (maybe) harder to introduce space/time leaks. > > Advantages of Reactive: > ? More functional programming like -- doesn't require you to use > arrows everywhere, and supports a nice applicative style. > ? In very active development. > ? Active community. I have not used Reactive as such, but I did use "Classic FRP" extensively, and as far as I know the setup is similar, even if Reactive has a modern and more principled interface. Based on my Classic FRP experience (which may be out of date, if so, correct me), I'd say advantages of Yampa are: * More modular. Yampa's signal function type is explicitly parameterized on the input signal type. In Classic FRP and Reactive (as far as I know), the system input is implicitly connected to all signal functions (or behaviours) in the system. One consequence of this is that it there were issues with reusing Classical FRP for different kinds of systems inputs, and difficult to combine systems with different kinds of input. This was what prompted a parameterization on the type of the system input in the first place, which eventually led to Arrowized FRP and Yampa. I don't know what the current story of Reactive is in this respect. But having parameterized input has been crucial for work on big, mixed-domain, applications. (For example, a robot simulator with an interactive editor for setting up "the world". The robots were FRP systems too, but their input is naturally of a different kind that the overall system input. It also turned out to be very useful to have an FRP preprocessor for the system input, which then was composed with the rest of the system using what effectively was arrow composition (>>>), but called something else at the time.) * A clear separation between signals, signal functions, and ordinary functions and values, yet the ability to easily integrate all kinds of computations. Arguably a matter of taste, and in some ways more a consequence of the Arrow syntax than Arrows themselves. But in Classical FRP, one had to do either a lot of explicit lifting (in practice, we often ended up writing lifting wrappers for entire libraries), or try to exploit overloading for implicit lifting. The latter is quite limited though, partly due to how Haskell's type classes are organized and that language support for overloaded constants is limited to numerical constants. In any case, when we switched to arrows and arrow syntax, I found it liberating to not have to lift "everything" to signal functions first, but that I could program both with signals and signal functions on the one hand, and plain values and functions on the other, at the same time and fairly seamlessly. And personally, I also felt this made the programs conceptually clearer and easier to understand, My understanding is that Reactive is similar to Classical FRP in this respect. * Classical FRP lacked a satisfying approach to handle dynamic collections of reactive entities as needed when programming typical video games for example. Yampa has a way. One can argue about how satisfying it is, but at least it fulfills basic requirements such that allowing logically removed entities to be truly removed (garbage collected). I don't know where Reactive stands here. * There was also an issue with Classical FRP having to do with the need to observe the output from one part of the system in another part of the system. This is quite different from parameterizing the second part of the the system on the first, as this approach loses sharing across switches. This led to the development for "running in" constructs, which effectively made it possible for behaviours to be both signals (i.e. signal functions already applied to the system input), and signal functions (not yet applied to the system input). Yet there was no distinction between these "running behaviours" (= signals) and normal behaviours (= signal functions) at the type level. The approach also led to semantic difficulties, and, when trying to resolve those, to a very complicated design involving complicated overloading and auxiliary classes. The arrows approach obviated the need for all of this, and I consider that and other distinct advantage. Again, I don't know where Reactive stands here, but it needs to have a good answer to this issue, or it is going to suffer from limited expressivity. Many of the above advantages are matters of opinion (but so are the advantages initially put forward for Reactive above). However, the development of AFRP and Yampa was motivated by fundamental expresssivity limitations of Classical FRP, in at least some ways related to the very way the system was set up. To the extent Reactive is similar in style to Classical FRP, I think Reactive also needs to address those questions. All the best, /Henrik -- Henrik Nilsson School of Computer Science The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From 666wman at gmail.com Wed Dec 17 09:48:36 2008 From: 666wman at gmail.com (wman) Date: Wed Dec 17 09:41:14 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <20081217135740.GA10904@mithrandi.net> Message-ID: > > That's the kind of mentality I am talking about. The "we are better > than you" mentality, should stay with the Java and .NET people. If you > have this urge of feeling superior and believe haskell-hacking is some > kind of achievement..... . > Well, you are what many call "person who just can't take a joke". I'ts no about being better, it's abot that without curiosity and determination there is no space for embetterment. And would you object to it even if I rephrased it slightly (so even those used to seeing superiority all around them would feel comfortable) : Who cares about people who are afraid of discovering new stuff, who when they don't understand something rather than delving into it with pleasure just cover their eyes and start shouting "I don't wanna know, I don't wanna know" (or even better: "I already know _EVERYTHING_ i will ever need", or the most favorite one "Don't tell me how it works, just tell me what i should do"). > Haskell is a tool like any other, it's the ideas you manifest by it > that are important. And of course the way you do it. The logo should > be attractive; fire sparks of curiosity, represent what haskell is, > capture the essence of haskell. To me, new, unknown things are attractive (not that they might not turn disgusting ;-) ... And how do you capture the essence of math ? How do you, through a logo, tell someone that most of it's elegance comes from the fact that it's derived straight from the laws/rules that governs everything else ? Lambda _and_ a gray-bearded old fart sitting on a cloudlet, with a keyboard plugged into one of the earths poles ??? > Ps: This is no flame, I am making a point. If you feel this is a > flame; then I must apologize for the harsh tone. Oh, I've read that after finishing the reply. Ok, substract some irony from mine ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/49768a81/attachment.htm From tom.davie at gmail.com Wed Dec 17 11:05:30 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Dec 17 10:58:11 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <49490CB1.8060405@cs.nott.ac.uk> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> Message-ID: <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> I'll have an attempt at addressing the questions, although I freely admit that I'm not as "into" Reactive as Conal is yet, so he may come and correct me in a minute. On 17 Dec 2008, at 15:29, Henrik Nilsson wrote: > I have not used Reactive as such, but I did use "Classic FRP" > extensively, and as far as I know the setup is similar, even > if Reactive has a modern and more principled interface. > > Based on my Classic FRP experience (which may be out of date, if so, > correct me), I'd say advantages of Yampa are: > > * More modular. > > Yampa's signal function type is explicitly parameterized on the > input signal type. In Classic FRP and Reactive (as far as I know), > the system input is implicitly connected to all signal functions > (or behaviours) in the system. > > One consequence of this is that it there were issues with reusing > Classical FRP for different kinds of systems inputs, and difficult > to combine systems with different kinds of input. This was what > prompted a parameterization on the type of the system input in the > first place, which eventually led to Arrowized FRP and Yampa. > > I don't know what the current story of Reactive is in this respect. > But having parameterized input has been crucial for work on big, > mixed-domain, applications. (For example, a robot simulator with an > interactive editor for setting up "the world". The robots were > FRP systems too, but their input is naturally of a different kind > that the overall system input. It also turned out to be very useful > to have an FRP preprocessor for the system input, which then was > composed with the rest of the system using what effectively was > arrow composition (>>>), but called something else at the time.) I'm not sure how this was set up in a classic FRP system, so I'm unable to comment on how exactly it's changed. What I will say is that as far I understand what you're saying, Reactive has explicitly parameterized inputs. In your robot example I would expect something along the lines of data RobotInputs = RI {lightSensor :: Behavior Colour; bumbSwitch :: Event ()} -- A couple of example robot sensors robotBehavior :: RobotInputs -> Behavior Robot robotBehavior sensors = a behovior that combines the light sensor and the bumb switch to stay in the light, but not keep driving into things. data UIInputs = UI {mousePoint :: Behavior Point; mouseClick :: Event (); ...} world :: UIInputs -> Behavior World world = interpret mouse and produce a world with barriers, robots and lights in it robotInputs :: World -> Behavior Robot -> RobotInputs robotInputs = given a robot in a world, generate the robot's inputs > * A clear separation between signals, signal functions, and ordinary > functions and values, yet the ability to easily integrate all kinds > of computations. > > Arguably a matter of taste, and in some ways more a consequence of > the Arrow syntax than Arrows themselves. But in Classical FRP, > one had to do either a lot of explicit lifting (in practice, we > often ended up writing lifting wrappers for entire libraries), or > try to exploit overloading for implicit lifting. The latter is > quite limited though, partly due to how Haskell's type classes > are organized and that language support for overloaded constants > is limited to numerical constants. > > In any case, when we switched to arrows and arrow syntax, I found > it liberating to not have to lift "everything" to signal functions > first, but that I could program both with signals and signal > functions on the one hand, and plain values and functions on the > other, at the same time and fairly seamlessly. And personally, > I also felt this made the programs conceptually clearer and easier > to understand, > > My understanding is that Reactive is similar to Classical FRP in > this respect. I agree and disagree here (that'll be the matter of taste creeping in). I agree that in Reactive you often spend a lot of keystrokes lifting pure values into either an Event or a Behavior. Having said that I'd argue that Yampa requires us to do this too -- it merely enforces the style in which we do it (we must do it with arrows). My personal opinion on this one is that I prefer the applicative interface to the arrow based one, because it feels more like just writing a functional program. > * Classical FRP lacked a satisfying approach to handle dynamic > collections of reactive entities as needed when programming > typical video games for example. Yampa has a way. One can > argue about how satisfying it is, but at least it fulfills > basic requirements such that allowing logically removed entities to > be truly removed (garbage collected). > > I don't know where Reactive stands here. I reserve judgement at the moment because I haven't explicitly written a reactive program involving a collection of behaviors, having said that, I see no reason why removing a value from the list in a Behavior [a], it should not get garbage collected. > * There was also an issue with Classical FRP having to do with the > need to observe the output from one part of the system in > another part of the system. This is quite different from > parameterizing the second part of the the system on the first, > as this approach loses sharing across switches. This led to the > development for "running in" constructs, which effectively > made it possible for behaviours to be both signals (i.e. > signal functions already applied to the system input), > and signal functions (not yet applied to the system input). > > Yet there was no distinction between these "running behaviours" > (= signals) and normal behaviours (= signal functions) at the > type level. The approach also led to semantic difficulties, and, > when trying to resolve those, to a very complicated design > involving complicated overloading and auxiliary classes. > > The arrows approach obviated the need for all of this, and > I consider that and other distinct advantage. > > Again, I don't know where Reactive stands here, but it needs to > have a good answer to this issue, or it is going to suffer from > limited expressivity. My understanding is that Conal went to great lengths to make sure that Behaviors get correctly cached, so that incremental values are only evaluated once, but I'm affraid I can't answer this more sensibly. > Many of the above advantages are matters of opinion (but so are the > advantages initially put forward for Reactive above). However, > the development of AFRP and Yampa was motivated by fundamental > expresssivity limitations of Classical FRP, in at least some ways > related to the very way the system was set up. To the extent Reactive > is similar in style to Classical FRP, I think Reactive also needs to > address those questions. Yep, I very much agree that these are mostly matters of taste, I hope I did something to answer some of the questions, and sorry I didn't give a better example particularly in the case of the last question. Your email triggered to think about a couple of the other significant differences between Yampa and Reactive * Reactive deals with continuous functions of time, not sampled ones. This allows for asynchronous sampling, for example the ability to sample a Behavior at 1/60th of a second rate for screen refreshes, while sampling the same behavior also at 1/10th second for logging, and 1/1000th for euler integration of un-integratable Behaviors. * Reactive is push based. The result of this is that we will not waste CPU cycles for example refreshing the screen when nothing has changed on the output. There are however a number of problems that Yampa certainly did solve that Reactive does not (yet), for example, recursive integrals do not yet always work correctly in Reactive (although when working, they should be totally transparent). It is also much harder to make a space leak in a Yampa program than in a Reactive one, thanks to the protective nest of Signal Functions. I think this is really a general problem of Haskell programming though -- it's possible to create space leaks, be careful! Thanks Tom Davie From tphyahoo at gmail.com Wed Dec 17 11:54:07 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Dec 17 11:46:56 2008 Subject: [Haskell-cafe] monadic versus aplicative style. These two snips seem to do the same thing yet one has a bug. Message-ID: <910ddf450812170854w24a635a5ka7423366faab4ac8@mail.gmail.com> Hi, I rewrote a piece of code that used applicative to use instead monadic style, basically because I wanted to adapt it for my own purposes but hadn't wrapped my head around applicative yet. Unfortunately my rewrite had a bug, which I'm still not completely clear on. (I am guessing it's a laziness mixed with IO issue.) I discarded my own version and am using the original now of course, but I'm curious if anyone has anything to say on the difference between these two bits of code and, in general if there is any way to "think" about the difference between monadic and applicative. For what it's worth, the code comes from HSTringTemplate (on hackage). The bug is described in http://groups.google.com/group/HAppS/browse_thread/thread/70d4b1fbe8a4c7ac Basically, in happs, this bit of code caused an unrelated handler to not fully pages correctly, where there was more than one image to load. It took forever to diagnose and track this down. Ugh. Thanks, thomas. -- incorrect behavior directoryGroup' :: (FilePath -> FilePath -> IO (StringTemplate a)) -> FilePath -> IO (STGroup a) directoryGroup' templatereader path = do fs <- return . ( filter ((".st" ==) . takeExtension) ) =<< getDirectoryContents path templates <- mapM (templatereader path) fs stmapping <- return $ zip fs templates return $ groupStringTemplates stmapping -- correct behavior --directoryGroup2' :: (Stringable a) => FilePath -> IO (STGroup a) directoryGroup'2 templatereader path = groupStringTemplates <$> (fmap <$> zip . (map dropExtension) <*> mapM ( templatereader path ) =<< filter ((".st" ==) . takeExtension) <$> getDirectoryContents path) From tphyahoo at gmail.com Wed Dec 17 11:57:53 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Dec 17 11:50:44 2008 Subject: [Haskell-cafe] Re: monadic versus aplicative style. These two snips seem to do the same thing yet one has a bug. In-Reply-To: <910ddf450812170854w24a635a5ka7423366faab4ac8@mail.gmail.com> References: <910ddf450812170854w24a635a5ka7423366faab4ac8@mail.gmail.com> Message-ID: <910ddf450812170857i51fe0b1ah1c38885b5dc1f572@mail.gmail.com> The commented-out signature is incorrect. Of course, the two functions have the same type sig. 2008/12/17 Thomas Hartman : > Hi, > > I rewrote a piece of code that used applicative to use instead > monadic style, basically because I wanted to adapt it for my own > purposes but hadn't wrapped my head around applicative yet. > > Unfortunately my rewrite had a bug, which I'm still not completely > clear on. (I am guessing it's a laziness mixed with IO issue.) > > I discarded my own version and am using the original now of course, > but I'm curious if anyone has anything to say on the difference > between these two bits of code and, in general if there is any way to > "think" about the difference between monadic and applicative. > > For what it's worth, the code comes from HSTringTemplate (on > hackage). The bug is described in > > http://groups.google.com/group/HAppS/browse_thread/thread/70d4b1fbe8a4c7ac > > Basically, in happs, this bit of code caused an unrelated handler to > not fully pages correctly, where there was more than one image to > load. It took forever to diagnose and track this down. Ugh. > > Thanks, thomas. > > -- incorrect behavior > directoryGroup' :: (FilePath -> FilePath -> IO (StringTemplate a)) -> > FilePath -> IO (STGroup a) > directoryGroup' templatereader path = do > fs <- return . ( filter ((".st" ==) . takeExtension) ) =<< > getDirectoryContents path > templates <- mapM (templatereader path) fs > stmapping <- return $ zip fs templates > return $ groupStringTemplates stmapping > > -- correct behavior > --directoryGroup2' :: (Stringable a) => FilePath -> IO (STGroup a) > directoryGroup'2 templatereader path = groupStringTemplates <$> > (fmap <$> zip . (map dropExtension) > <*> mapM ( templatereader path ) > =<< filter ((".st" ==) . takeExtension) > <$> getDirectoryContents path) > From jeff at nokrev.com Wed Dec 17 11:58:41 2008 From: jeff at nokrev.com (Jeff Wheeler) Date: Wed Dec 17 11:51:28 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <1229533121.5751.7.camel@ulysses.home> On Wed, 2008-12-17 at 08:42 -0500, Darrin Thompson wrote: > If you play with the angles and vary the stroke thicknesses you'll > probably get a friendlier look, vs. the military/airline look these > have now. The first '>' doesn't have to be the same thickness as the > lambda. > > Just another $0.02 us. Thanks for running with it. Those look like I imagined. Thanks for the feedback. I've made two versions[1][2] with subtle rounded edges, although now it becomes evident that I have no design skills. :) I tried giving them varying thicknesses, but I couldn't get anything to look quite right. Everybody is welcome to hack it; I've uploaded a PSD [3] (Photoshop src file); unfortunately, I don't have Illustrator and Inkscape is failing to compile. It might be easier for people to hack if somebody could convert this to an Inkscape file. :-/ > X monad could have a variant of this logo too. >X= (That's how I > originally thought of it, just was too lazy to post it anywhere. Sorry > about that.) I like that too; not sure what to do for Yi, though. Anybody mind if I add these to the wiki, too? I feel like I'm taking up tons of space, there. Jeff Wheeler [1] http://media.nokrev.com/junk/haskell-logos/logo8.png [2] http://media.nokrev.com/junk/haskell-logos/logo9.png [3] http://media.nokrev.com/junk/haskell-logos/logo-rounded.psd -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/06b5a394/attachment.bin From tphyahoo at gmail.com Wed Dec 17 12:30:57 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Dec 17 12:23:36 2008 Subject: [Haskell-cafe] Re: monadic versus aplicative style. These two snips seem to do the same thing yet one has a bug. In-Reply-To: <910ddf450812170857i51fe0b1ah1c38885b5dc1f572@mail.gmail.com> References: <910ddf450812170854w24a635a5ka7423366faab4ac8@mail.gmail.com> <910ddf450812170857i51fe0b1ah1c38885b5dc1f572@mail.gmail.com> Message-ID: <910ddf450812170930q1242d079s46b82f0d3fddd46e@mail.gmail.com> It was pointed out to me that there are other differences besides monadic versus applicative, and now I'm thinking I misdiagnosed the bug after all. sorry for the spam. 2008/12/17 Thomas Hartman : > The commented-out signature is incorrect. > > Of course, the two functions have the same type sig. > > 2008/12/17 Thomas Hartman : >> Hi, >> >> I rewrote a piece of code that used applicative to use instead >> monadic style, basically because I wanted to adapt it for my own >> purposes but hadn't wrapped my head around applicative yet. >> >> Unfortunately my rewrite had a bug, which I'm still not completely >> clear on. (I am guessing it's a laziness mixed with IO issue.) >> >> I discarded my own version and am using the original now of course, >> but I'm curious if anyone has anything to say on the difference >> between these two bits of code and, in general if there is any way to >> "think" about the difference between monadic and applicative. >> >> For what it's worth, the code comes from HSTringTemplate (on >> hackage). The bug is described in >> >> http://groups.google.com/group/HAppS/browse_thread/thread/70d4b1fbe8a4c7ac >> >> Basically, in happs, this bit of code caused an unrelated handler to >> not fully pages correctly, where there was more than one image to >> load. It took forever to diagnose and track this down. Ugh. >> >> Thanks, thomas. >> >> -- incorrect behavior >> directoryGroup' :: (FilePath -> FilePath -> IO (StringTemplate a)) -> >> FilePath -> IO (STGroup a) >> directoryGroup' templatereader path = do >> fs <- return . ( filter ((".st" ==) . takeExtension) ) =<< >> getDirectoryContents path >> templates <- mapM (templatereader path) fs >> stmapping <- return $ zip fs templates >> return $ groupStringTemplates stmapping >> >> -- correct behavior >> --directoryGroup2' :: (Stringable a) => FilePath -> IO (STGroup a) >> directoryGroup'2 templatereader path = groupStringTemplates <$> >> (fmap <$> zip . (map dropExtension) >> <*> mapM ( templatereader path ) >> =<< filter ((".st" ==) . takeExtension) >> <$> getDirectoryContents path) >> > From v.dijk.bas at gmail.com Wed Dec 17 13:20:43 2008 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Dec 17 13:13:20 2008 Subject: [Haskell-cafe] How to choose an arbitrary Arbitrary? Message-ID: Hello, I was playing with the following tree type (attached below) which can be seen as the reification of an applicative. I wondered if I could define a QuickCheck Arbitrary instance for it. The only way I got it to type check however, was to give 'arg' a monomorphic type (for example: 'Gen (Tree ())'). If I left it polymorphic I got a "Ambiguous type variable in constraints" error. This is understandable because if the subtrees have polymorphic types they can be of any type: Tree Int, Tree Float, Tree String, etc. The system then doesn't know which Arbitrary to choose. My question is, is it possible to keep 'arg' polymorphic (i.e. 'Gen (Tree b)') and let the system somehow choose an arbitrary Arbitrary? I guess not, however I like to be proven wrong. regards, Bas ---------------------------------------------------- {-# LANGUAGE ExistentialQuantification #-} module Tree where import Control.Monad import Test.QuickCheck -- I'm using QuickCheck-2.1.0.1 data Tree a = Val a | forall b. Tree (b -> a) :*: Tree b instance Arbitrary a => Arbitrary (Tree a) where arbitrary = sized sizedTree sizedTree :: (Arbitrary a) => Int -> Gen (Tree a) sizedTree n | n <= 0 = liftM Val arbitrary | otherwise = liftM2 (:*:) func arg where m = n `div` 2 func = sizedTree m arg :: Gen (Tree ()) -- how to make this: -- Gen (Tree b) ??? arg = sizedTree m ---------------------------------------------------- From bhurt at spnz.org Wed Dec 17 13:36:03 2008 From: bhurt at spnz.org (Brian Hurt) Date: Wed Dec 17 13:28:48 2008 Subject: [Haskell-cafe] Please tell me this function exists Message-ID: I know it's not hard to write, but still: concat :: String -> [String] -> String concat _ [] = "" concat _ [x] = x concat sep x:xs = x ++ sep ++ (concat sep xs) I've got to be stupid and missing it in the standard libraries. Please tell me where. Thanks. Brian From max.rabkin at gmail.com Wed Dec 17 13:39:59 2008 From: max.rabkin at gmail.com (Max Rabkin) Date: Wed Dec 17 13:32:40 2008 Subject: [Haskell-cafe] Please tell me this function exists In-Reply-To: References: Message-ID: Hoogle is your friend: Searching for String -> [String] -> String Data.List intercalate :: [a] -> [[a]] -> [a] base intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the... Regards, Max On Wed, Dec 17, 2008 at 10:36 AM, Brian Hurt wrote: > > I know it's not hard to write, but still: > > concat :: String -> [String] -> String > concat _ [] = "" > concat _ [x] = x > concat sep x:xs = x ++ sep ++ (concat sep xs) > > I've got to be stupid and missing it in the standard libraries. Please tell > me where. Thanks. > > Brian > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From v.dijk.bas at gmail.com Wed Dec 17 13:40:37 2008 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Dec 17 13:33:13 2008 Subject: [Haskell-cafe] Please tell me this function exists In-Reply-To: References: Message-ID: On Wed, Dec 17, 2008 at 7:36 PM, Brian Hurt wrote: > > I know it's not hard to write, but still: > > concat :: String -> [String] -> String > concat _ [] = "" > concat _ [x] = x > concat sep x:xs = x ++ sep ++ (concat sep xs) > > I've got to be stupid and missing it in the standard libraries. Please tell > me where. Thanks. Just hoogle the type: http://haskell.org/hoogle/?hoogle=String+-%3E+[String]+-%3E+String and see the first hit. regards, Bas From daniel.is.fischer at web.de Wed Dec 17 13:43:23 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Dec 17 13:33:33 2008 Subject: [Haskell-cafe] Please tell me this function exists In-Reply-To: References: Message-ID: <200812171943.23317.daniel.is.fischer@web.de> Am Mittwoch, 17. Dezember 2008 19:36 schrieb Brian Hurt: > I know it's not hard to write, but still: > > concat :: String -> [String] -> String > concat _ [] = "" > concat _ [x] = x > concat sep x:xs = x ++ sep ++ (concat sep xs) > > I've got to be stupid and missing it in the standard libraries. Please > tell me where. Thanks. > > Brian Data.List.intersperse and concat together do exactly that: yourconcat === (concat .) . intersperse From daniel.is.fischer at web.de Wed Dec 17 13:45:52 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Dec 17 13:36:02 2008 Subject: [Haskell-cafe] Please tell me this function exists In-Reply-To: References: Message-ID: <200812171945.52591.daniel.is.fischer@web.de> Am Mittwoch, 17. Dezember 2008 19:36 schrieb Brian Hurt: > I know it's not hard to write, but still: > > concat :: String -> [String] -> String > concat _ [] = "" > concat _ [x] = x > concat sep x:xs = x ++ sep ++ (concat sep xs) > > I've got to be stupid and missing it in the standard libraries. Please > tell me where. Thanks. > > Brian I just remembered Data.List.intercalate. From bhurt at spnz.org Wed Dec 17 13:44:26 2008 From: bhurt at spnz.org (Brian Hurt) Date: Wed Dec 17 13:37:10 2008 Subject: [Haskell-cafe] Please tell me this function exists In-Reply-To: References: Message-ID: On Wed, 17 Dec 2008, Max Rabkin wrote: > Hoogle is your friend: > > Searching for String -> [String] -> String > Data.List intercalate :: [a] -> [[a]] -> [a] > base > intercalate xs xss is equivalent to (concat (intersperse xs xss)). It > inserts the... > Thanks. Brian From martijn at van.steenbergen.nl Wed Dec 17 15:46:17 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Dec 17 15:38:56 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <49496519.5010409@van.steenbergen.nl> Darrin Thompson wrote: > On Tue, Dec 16, 2008 at 9:47 PM, Jeff Wheeler wrote: >> [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png >> [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png >> >> > > Oops, I meant to post on list. > > If you play with the angles and vary the stroke thicknesses you'll > probably get a friendlier look, vs. the military/airline look these > have now. The first '>' doesn't have to be the same thickness as the > lambda. If you look at fonts: characters in a font aren't all straight either; they bend a bit (so that is more than just round corners) and this makes them a lot more interesting. Various levels of bendiness yield various levels of "playfulness". While I already like this logo a lot, I think it could be improved a lot more by making it more "fonty". Note that I'm not saying it should be a very playful logo, just a more fonty one... yeah. Martijn. From porges at porg.es Wed Dec 17 15:55:12 2008 From: porges at porg.es (George Pollard) Date: Wed Dec 17 15:48:11 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <49496519.5010409@van.steenbergen.nl> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <49496519.5010409@van.steenbergen.nl> Message-ID: <1229547312.1787.6.camel@porges-laptop> On Wed, 2008-12-17 at 21:46 +0100, Martijn van Steenbergen wrote: > > If you play with the angles and vary the stroke thicknesses you'll > > probably get a friendlier look, vs. the military/airline look these > > have now. The first '>' doesn't have to be the same thickness as the > > lambda. > > If you look at fonts: characters in a font aren't all straight either; > they bend a bit (so that is more than just round corners) and this makes > them a lot more interesting. Various levels of bendiness yield various > levels of "playfulness". While I already like this logo a lot, I think > it could be improved a lot more by making it more "fonty". Note that I'm > not saying it should be a very playful logo, just a more fonty one... yeah. Might be interesting to try angling the ends of the stems to look something more like the guillemot in [1]. I might try this in Gimp but I'm no designer :P [1] http://haskell.org/sitewiki/images/6/62/Haskell_logo_ideas_falconnl.png -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081218/ee9add9e/attachment.bin From andrewcoppin at btinternet.com Wed Dec 17 16:31:23 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 17 16:24:01 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <1229462441.17249.6.camel@jcchost> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <1229462441.17249.6.camel@jcchost> Message-ID: <49496FAB.4050002@btinternet.com> Jonathan Cast wrote: >> {-# LANGUAGE ExistentialQuantification #-} >> >> Hmm, now if this was Perl or something, that would be >> HiddenTypeVariables or something. Much less fearsom-sounding. >> > > No, it's cute. Repulsively so. > Right. So giving things meaningful names is "repulsive"? No wonder Haskell has a reputation for being incomprehensible... >> At any rate, if we're to have a logo, let's not have one which actively >> *promotes* the notion that Haskell is complex and difficult and that >> only theoretical physicists need apply... >> > > I'd like to hold out, again, for the idea that we get a higher-quality > community by promoting that notion. > In other words, you want to keep Haskell elitist. Well, if that's what the community in general wants, then fine. Personally, I strongly disagree with this snobbish point of view. But I am only one voice... From andrewcoppin at btinternet.com Wed Dec 17 16:34:15 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 17 16:26:54 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <49497057.9000807@btinternet.com> Jeff Wheeler wrote: > [1]: http://media.nokrev.com/junk/haskell-logos/logo1.png > [2]: http://media.nokrev.com/junk/haskell-logos/logo2.png > As others have said: - I very much like the concept of this. It's clean, simple, elegant. Like Haskell! - Yeah, it does look a tad harsh. Maybe curvy edges? From dons at galois.com Wed Dec 17 16:35:03 2008 From: dons at galois.com (Don Stewart) Date: Wed Dec 17 16:27:43 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49496FAB.4050002@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <1229462441.17249.6.camel@jcchost> <49496FAB.4050002@btinternet.com> Message-ID: <20081217213503.GB8927@scytale.galois.com> andrewcoppin: > Jonathan Cast wrote: > >>{-# LANGUAGE ExistentialQuantification #-} > >> > >>Hmm, now if this was Perl or something, that would be > >>HiddenTypeVariables or something. Much less fearsom-sounding. > >> > > > >No, it's cute. Repulsively so. > > > > Right. So giving things meaningful names is "repulsive"? No wonder > Haskell has a reputation for being incomprehensible... > > >>At any rate, if we're to have a logo, let's not have one which actively > >>*promotes* the notion that Haskell is complex and difficult and that > >>only theoretical physicists need apply... > >> > > > >I'd like to hold out, again, for the idea that we get a higher-quality > >community by promoting that notion. > > > > In other words, you want to keep Haskell elitist. Well, if that's what > the community in general wants, then fine. Personally, I strongly > disagree with this snobbish point of view. But I am only one voice... Chillax peoples. We'll all be able to vote on logos cute or otherwise in January. Until Dec 31, continue uploading useful suggestions and variants to the submissions page http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas From jonathanccast at fastmail.fm Wed Dec 17 16:35:28 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Dec 17 16:28:40 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49496FAB.4050002@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <1229462441.17249.6.camel@jcchost> <49496FAB.4050002@btinternet.com> Message-ID: <1229549728.27994.10.camel@jcchost> On Wed, 2008-12-17 at 21:31 +0000, Andrew Coppin wrote: > Jonathan Cast wrote: > >> {-# LANGUAGE ExistentialQuantification #-} > >> > >> Hmm, now if this was Perl or something, that would be > >> HiddenTypeVariables or something. Much less fearsom-sounding. > >> > > > > No, it's cute. Repulsively so. > > > > Right. So giving things meaningful names is "repulsive"? I reject your belief that `HiddenTypeVariables' is more meaningful than `ExistentialQuantification'. Meaning comes from previous usage, and your neologism doesn't have any. > >> At any rate, if we're to have a logo, let's not have one which actively > >> *promotes* the notion that Haskell is complex and difficult and that > >> only theoretical physicists need apply... > >> > > > > I'd like to hold out, again, for the idea that we get a higher-quality > > community by promoting that notion. > > > > In other words, you want to keep Haskell elitist. I think there's value in having elites around. jcc From porges at porg.es Wed Dec 17 16:36:00 2008 From: porges at porg.es (George Pollard) Date: Wed Dec 17 16:29:01 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <1229547312.1787.6.camel@porges-laptop> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <49496519.5010409@van.steenbergen.nl> <1229547312.1787.6.camel@porges-laptop> Message-ID: <1229549760.1787.7.camel@porges-laptop> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081218/b7bfde5d/attachment.bin From andrewcoppin at btinternet.com Wed Dec 17 16:39:24 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 17 16:32:00 2008 Subject: [Haskell-cafe] Implementing PacMan In-Reply-To: <49481D34.4050107@cs.nott.ac.uk> References: <494812DB.8060902@btinternet.com> <49481D34.4050107@cs.nott.ac.uk> Message-ID: <4949718C.70205@btinternet.com> Henrik Nilsson wrote: > Hi, > > > Thoughts, people? > > Functional Reactive Programming (FRP) tends to, in principle, work > pretty well for this kind of application. So I keep hearing. Unfortunately, discovering what FRP actually *means* is more or less impossible. I can't find a precise definition of the term anywhere. There are a small handful of libraries which claim to "implement it", and their documentation generally isn't especially helpful. Too many trees for me to actually see the wood - i.e., what it's doing and why that's helpful. > The page you referred to didn't seem to consider FRP? There's a tiny footnote at the end muttering something about "next I need to figure out how FRP fits into the picture", but that's it. > Don't know if FRP would address all of your concerns. The guy has written a number of posts on the topic, and one of his criticisms is that "FRP is supposed to 'fix' this, but every FRP demo is bouncing balls or asteroids or something equally trivial". I don't know if he wrote that before Frag - isn't that FRP? > But as to collisions, we can observe that this involves two or more > entities and > is, from the perspective of each entity, something external. Thus > I don't think it's unreasonable that code handling collision detection > is done "somewhere else", meaning outside the code describing the game > entities themselves. A reasonably argument... > As to how to respond to collisions, that can be > a great deal trickier. Is that not always the way? ;-) From andrewcoppin at btinternet.com Wed Dec 17 16:41:46 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 17 16:34:23 2008 Subject: [Haskell-cafe] Implementing PacMan In-Reply-To: <2f9b2d30812170014t62e011a7h4a1dca777799ad63@mail.gmail.com> References: <494812DB.8060902@btinternet.com> <2f9b2d30812170013q83f8e9bp4927e0caa598025a@mail.gmail.com> <2f9b2d30812170014t62e011a7h4a1dca777799ad63@mail.gmail.com> Message-ID: <4949721A.5050601@btinternet.com> Ryan Ingram wrote: > Oops, misread a bit. I thought this was your series of posts, Andrew! > But other than that, my points stand :) > Don't you just *hate* it when you reply, and then later realise you missed some small but important detail? ;-) As for your actual content... I will have to meditate deeply on this to comprehend if/why it's helpful here. (As with all good ideas!) > On Wed, Dec 17, 2008 at 12:13 AM, Ryan Ingram wrote: > >> In the last "episode" you talk about an entity's update being a function like: >> >> >>> input_state -> (output_state, [event]) >>> >> for some suitably defined types of input state, output state, and event. >> >> Connecting together functions with types like this is exactly what >> Reactive does well. You have an event stream representing the >> behavior of the user during the course of the game, and you use that >> to construct other values representing the *behavior* of the game. >> The key difference is that instead of the game's behavior being a set >> of functions from input to output, it is functions from one behavior >> to another, eventually culminating in something like >> >> >>> -- "user input", "clock tick"; output a new display list at each clock tick >>> game :: Event UserInput -> Event () -> Reactive [RenderCommand] >>> >> In fact, I think your analysis in the first message is somewhat right >> on; this exercise is somewhat like "writing a novel without using the >> letter 'e'". The benefits you get from a pure language are not >> necessarily "lack of effects", but rather, "explicitly mentioning >> where effects happen". >> >> That said, I'm curious where you are going with it. I'd love to see >> the game running & take a look at your code! >> >> -- ryan >> From andrewcoppin at btinternet.com Wed Dec 17 16:48:45 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 17 16:41:21 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <494973BD.2070303@btinternet.com> Darrin Thompson wrote: > What I like about the design is anybody can draw it in 5 strokes and > it's unmistakably what it is. Sharpie, pencil, even spray paint all > work. You could make your own hat or t-shirt and wear it to an > important event, or a wedding. You could tag a rival cube farm wall to > declare some kind of office war. > +1 From jeff at nokrev.com Wed Dec 17 16:53:19 2008 From: jeff at nokrev.com (Jeff Wheeler) Date: Wed Dec 17 16:45:46 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <1229547312.1787.6.camel@porges-laptop> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <49496519.5010409@van.steenbergen.nl> <1229547312.1787.6.camel@porges-laptop> Message-ID: <1229550799.5751.9.camel@ulysses.home> On Thu, 2008-12-18 at 09:55 +1300, George Pollard wrote: > Might be interesting to try angling the ends of the stems to look > something more like the guillemot in [1]. I might try this in Gimp but > I'm no designer :P Unfortunately, neither am I. :P The curvey version (3rd and 4th images on the wiki) is about the extent of my graphic ability, but I'll try to give it a shot regardless. Thanks for the feedback. :) Jeff Wheeler -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/b92db16d/attachment.bin From daniel.is.fischer at web.de Wed Dec 17 17:00:25 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Dec 17 16:50:38 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <1229549728.27994.10.camel@jcchost> References: <20081214211504.GO27904@scytale.galois.com> <49496FAB.4050002@btinternet.com> <1229549728.27994.10.camel@jcchost> Message-ID: <200812172300.25077.daniel.is.fischer@web.de> Am Mittwoch, 17. Dezember 2008 22:35 schrieb Jonathan Cast: > On Wed, 2008-12-17 at 21:31 +0000, Andrew Coppin wrote: > > In other words, you want to keep Haskell elitist. > > I think there's value in having elites around. Yes, but not if they're elitist :-) Seriously, I hope you're deliberately overstating your point. > > jcc From andrewcoppin at btinternet.com Wed Dec 17 16:58:55 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 17 16:51:35 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <20081217135740.GA10904@mithrandi.net> Message-ID: <4949761F.7050104@btinternet.com> Gianfranco Alongi wrote: > That's the kind of mentality I am talking about. The "we are better > than you" mentality, should stay with the Java and .NET people. If you > have this urge of feeling superior and believe haskell-hacking is some > kind of achievement..... . > > Haskell is a tool like any other, it's the ideas you manifest by it > that are important. And of course the way you do it. The logo should > be attractive; fire sparks of curiosity, represent what haskell is, > capture the essence of haskell. > Amen to that! From kili at outback.escape.de Wed Dec 17 16:57:56 2008 From: kili at outback.escape.de (Matthias Kilian) Date: Wed Dec 17 16:52:45 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <49497057.9000807@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <49497057.9000807@btinternet.com> Message-ID: <20081217215756.GA18333@petunia.outback.escape.de> On Wed, Dec 17, 2008 at 09:34:15PM +0000, Andrew Coppin wrote: > - I very much like the concept of this. It's clean, simple, elegant. > Like Haskell! But Haskell isn't Clean. (SCNR) Ciao, Kili From ryani.spam at gmail.com Wed Dec 17 17:05:41 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Dec 17 16:58:21 2008 Subject: [Haskell-cafe] How to choose an arbitrary Arbitrary? In-Reply-To: References: Message-ID: <2f9b2d30812171405y43599168p9e077c291068d01e@mail.gmail.com> It's absolutely possible. However, I think you do need to enumerate the possible types somehow. Here's an example that demonstrates the idea: > {-# LANGUAGE ScopedTypeVariables #-} > sizedTree :: forall a. Arbitrary a => Int -> Gen (Tree a) > sizedTree n | n <= 0 = liftM Val arbitrary > sizedTree n = oneof trees > where > m = n `div` 2 > mkTree :: forall b. Arbitrary b => b -> Gen (Tree a) > mkTree _ = liftM2 (:*:) (sizedTree m) (sizedTree m :: Gen (Tree b)) > > -- "b" can be Int, (), or Int -> Int > trees = > [ mkTree (undefined :: Int) > , mkTree (undefined :: ()) > , mkTree (undefined :: Int -> Int) > ] It's possible to extend this idea and generate an "arbitrary arbitrary": > -- "held" value is always _|_ > data SomeArbitrary = forall a. Arbitrary a => SomeArbitrary a > instance Arbitrary SomeArbitrary where > arbitrary = oneof > [ return (SomeArbitrary (undefined :: Int)) > , return (SomeArbitrary (undefined :: ())) > , arbFn > ] > where > arbFn = do > SomeArbitrary t1 <- arbitrary > SomeArbitrary t2 <- arbitrary > return (SomeArbitrary (undefined `asTypeOf` fn t1 t2)) > fn :: forall a b. a -> b -> (a -> b) > fn = undefined In this code, I am relying on certain instances of Arbitrary being present, in particular: instance Arbitrary Int instance Arbitrary () instance (Arbitrary a, Arbitrary b) => Arbitrary (a -> b) Pattern matching on t1 and t2 brings existential type variables into scope; you can then use those type variables to construct a new, more complicated type and stuff it back into another existential. The existential, conveniently, also holds the dictionary for Arbitrary, so you can generate values of those types while it is in scope. A better implementation would also include some way to implement an interesting "coarbitrary", but I'll leave that as an exercise. This all said, once things get stuffed into the existential in "Tree", there isn't much you can do with them. As declared, Tree is isomorphic to (Either a a) because there is no way to provide a different object of type b to call the (b -> a) function with (aside from unsafeCoerce shenanigans). -- ryan On Wed, Dec 17, 2008 at 10:20 AM, Bas van Dijk wrote: > Hello, > > I was playing with the following tree type (attached below) which can > be seen as the reification of an applicative. I wondered if I could > define a QuickCheck Arbitrary instance for it. > > The only way I got it to type check however, was to give 'arg' a > monomorphic type (for example: 'Gen (Tree ())'). If I left it > polymorphic I got a "Ambiguous type variable in constraints" error. > This is understandable because if the subtrees have polymorphic types > they can be of any type: Tree Int, Tree Float, Tree String, etc. The > system then doesn't know which Arbitrary to choose. > > My question is, is it possible to keep 'arg' polymorphic (i.e. 'Gen > (Tree b)') and let the system somehow choose an arbitrary Arbitrary? > > I guess not, however I like to be proven wrong. > > regards, > > Bas > > ---------------------------------------------------- > > {-# LANGUAGE ExistentialQuantification #-} > > module Tree where > > import Control.Monad > import Test.QuickCheck -- I'm using QuickCheck-2.1.0.1 > > data Tree a = Val a > | forall b. Tree (b -> a) :*: Tree b > > instance Arbitrary a => Arbitrary (Tree a) where > arbitrary = sized sizedTree > > sizedTree :: (Arbitrary a) => Int -> Gen (Tree a) > sizedTree n | n <= 0 = liftM Val arbitrary > | otherwise = liftM2 (:*:) func arg > where > m = n `div` 2 > > func = sizedTree m > > arg :: Gen (Tree ()) -- how to make this: > -- Gen (Tree b) ??? > arg = sizedTree m > > ---------------------------------------------------- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Wed Dec 17 17:26:58 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Dec 17 17:19:34 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081217140137.GB10904@mithrandi.net> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> Message-ID: <49497CB2.2030507@btinternet.com> Tristan Seligmann wrote: > * Andrew Coppin [2008-12-16 20:23:50 +0000]: > > >> Sure, there are many concepts in Haskell which just aren't found >> anywhere else. But monads? Catamorphisms? Coroutines? Couldn't we think >> up some less intimidating terminology? >> > > The problem is that "less intimidating" terminology generally seems to > mean inaccurate or misleading terminology. I'm not sure I agree with that. Sure, simplifying things *can* make them less precise. But I don't believe it is always necessarily so. And I think we could try a little bit harder here. (Nothing too radical, just some small changes.) > They aren't concepts that > aren't found anywhere else, they're concepts that *are* found elsewhere > (category theory, among other places), that's why they have those names. > And who knows category theory? Almost nobody. If you insist on naming stuff after things that nobody will have heard of and which sound highly technical, you're going to seriously limit your potential audience. (Hylomorphisms verses epimorphisms. Anybody remember which is which?) > (Also, "coroutines"? Seriously? That's hardly an obscure term in > programming circles.) > Well now, I'm curios. I've been writing computer programs since I was 9 years old. I hold a diploma *and* an honours degree in computer science. And I have never even *heard* of a coroutine. To this day I still don't know what it means. I rather suspect I'm not the only "programmer" on earth who finds themselves in this position. ;-) >> {-# LANGUAGE ExistentialQuantification #-} >> >> Hmm, now if this was Perl or something, that would be >> HiddenTypeVariables or something. Much less fearsom-sounding. >> > > Also much less informative, and less accurate. How so? Turning on this extension allows you to "hide" a type variable from the RHS of a data statement from appearing on the LHS. That's *exactly* what this extension does. What could be more descriptive? (Without launching into advanced logic theory anyway...) > The fact that Haskell > embraces its mathematical basis instead of trying to completely > obfuscate it away is not a bad thing, in my opinion. > I don't see how having a pronouncible name for something is "obfuscation". It's good that Haskell's mathematical foundations show through, but it would be bad if Haskell were completely opaque without first doing a postdoc in category theory. Technical terms are only useful to those who already know what they mean, after all. (We don't talk about "single-valued total relations", we talk about "functions". Because nobody knows what the heck a single-valued total relation is, but most people immediately "get" what a funtion is.) >> But then, I guess that's what you get for a lanuage designed by a >> committee of university professors. ;-) >> >> At any rate, if we're to have a logo, let's not have one which actively >> *promotes* the notion that Haskell is complex and difficult and that >> only theoretical physicists need apply... >> > > I think you're reading way too much into a logo. > The current logo is basically a circle plus a whole heap of mathematical symbols. That doesn't really say "hey, this stuff is fun, come on in!" It says "this is for maths nerds only". (Which isn't actually true, in my opinion. But the current logo gives that impression.) I'd like our new logo to do better in this direction, that's all. From dons at galois.com Wed Dec 17 17:30:50 2008 From: dons at galois.com (Don Stewart) Date: Wed Dec 17 17:23:25 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49497CB2.2030507@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> Message-ID: <20081217223050.GK8927@scytale.galois.com> > > The current logo is basically a circle plus a whole heap of mathematical > symbols. That doesn't really say "hey, this stuff is fun, come on in!" > It says "this is for maths nerds only". (Which isn't actually true, in > my opinion. But the current logo gives that impression.) I'd like our > new logo to do better in this direction, that's all. > Please contribute logos. -- Don From andrei.formiga at gmail.com Wed Dec 17 17:52:53 2008 From: andrei.formiga at gmail.com (Andrei Formiga) Date: Wed Dec 17 17:45:33 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49497CB2.2030507@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> Message-ID: On Wed, Dec 17, 2008 at 7:26 PM, Andrew Coppin wrote: >> >> (Also, "coroutines"? Seriously? That's hardly an obscure term in >> programming circles.) >> > > Well now, I'm curios. I've been writing computer programs since I was 9 > years old. I hold a diploma *and* an honours degree in computer science. And > I have never even *heard* of a coroutine. To this day I still don't know > what it means. I rather suspect I'm not the only "programmer" on earth who > finds themselves in this position. ;-) > I read about coroutines the first time a good number of years ago in "Programming in Modula-2" by Niklaus Wirth. It's true that they have fallen out of favor somewhat, but neither the concept nor the name are exclusive to Haskell. The fact is that programming is a technical endeavor, and as any other technical field, it needs jargon. Of course, it's always possible to overuse jargon, but I seriously don't know why anyone should be afraid of a name like "Existential Quantification". I understand some people are afraid of such a name, but it shouldn't be so. Well, this is getting back to Monads x WarmFuzzyThings... -- []s, Andrei Formiga From jonathanccast at fastmail.fm Wed Dec 17 18:50:37 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Dec 17 18:43:14 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <200812172300.25077.daniel.is.fischer@web.de> References: <20081214211504.GO27904@scytale.galois.com> <49496FAB.4050002@btinternet.com> <1229549728.27994.10.camel@jcchost> <200812172300.25077.daniel.is.fischer@web.de> Message-ID: <1229557837.6865.0.camel@jonathans-macbook> On Wed, 2008-12-17 at 23:00 +0100, Daniel Fischer wrote: > Am Mittwoch, 17. Dezember 2008 22:35 schrieb Jonathan Cast: > > On Wed, 2008-12-17 at 21:31 +0000, Andrew Coppin wrote: > > > In other words, you want to keep Haskell elitist. > > > > I think there's value in having elites around. > > Yes, but not if they're elitist :-) > Seriously, I hope you're deliberately overstating your point. I always deliberately over-state my points, it's funnier that way :) jcc From alexander.dunlap at gmail.com Wed Dec 17 18:55:28 2008 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Wed Dec 17 18:48:12 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <1229549760.1787.7.camel@porges-laptop> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <49496519.5010409@van.steenbergen.nl> <1229547312.1787.6.camel@porges-laptop> <1229549760.1787.7.camel@porges-laptop> Message-ID: <57526e770812171555k6454e611h5c88fda17cbd1c55@mail.gmail.com> 2008/12/17 George Pollard : >> Might be interesting to try angling the ends of the stems to look >> something more like the guillemot in [1]. I might try this in Gimp but >> I'm no designer :P > > Here is what I got; I think I chose the wrong yellow :) Based it on the > font Diavlo, which is free. > I love this one. From niklas.broberg at gmail.com Wed Dec 17 18:59:30 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Wed Dec 17 18:55:42 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49497CB2.2030507@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> Message-ID: > And who knows category theory? Almost nobody. If you insist on naming stuff > after things that nobody will have heard of and which sound highly > technical, you're going to seriously limit your potential audience. If you insist on naming stuff ad hoc, you're going to seriously limit the appeal of the language for those who care about correctness and mathematical concepts. No matter which way you go, there'll be someone who isn't quite content. But there are already a plethora of languages out there that don't care about correctness. Haskell is one of few languages that cater to the scientific community primarily, and it has come where it is today because of that, of staying true to theory instead of taking the pragmatic approach. That's just one reason I prefer Haskell over all the mainstream languages. Also, you're picking examples that make it sound far worse than it really is. I don't have the least clue about category theory, but knowing what a hylomorphism is (which I don't) is hardly something you need to be a proficient Haskell programmer (which I am). Existential quantification on the other hand, that's really something every programmer should know what it is. Programming is an engineering art, and I wouldn't want my programs to be written by someone uneducated in such matters anymore than I would like my lines fixed by a self-taught electrician. We can and should expect something of the practitioners of our discipline. And we should set the bar accordingly, to induce the will to learn rather than a feeling that you don't need to know. That's not elitism, it's pragmatism, for the improvement of programs and programming. Oh, and I really like the \\= logo, very neat! :-) Cheers, /Niklas From jerzy.karczmarczuk at info.unicaen.fr Wed Dec 17 19:28:36 2008 From: jerzy.karczmarczuk at info.unicaen.fr (jerzy.karczmarczuk@info.unicaen.fr) Date: Wed Dec 17 19:21:15 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49497CB2.2030507@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> Message-ID: Andrew Coppin writes: > And who knows category theory? Almost nobody. If you insist on naming > stuff after things that nobody will have heard of and which sound highly > technical, you're going to seriously limit your potential audience. Speak for yourself, not for "almost everybody", or you will going to seriously limit your potential audience (which might be already restricted to those who don't care about seriousness of your statements). ALL mathematicians know CT. All formal papers on Monads touch CT. Well, OK, I know, Monads and you are two different worlds... >> (Also, "coroutines"? Seriously? That's hardly an obscure term in >> programming circles.) >> > > Well now, I'm curios. I've been writing computer programs since I was 9 > years old. I hold a diploma *and* an honours degree in computer science. > And I have never even *heard* of a coroutine. To this day I still don't > know what it means. I rather suspect I'm not the only "programmer" on > earth who finds themselves in this position. ;-) If one day I decide to return back to some religion, I will pray for the souls of your teachers. How many microseconds have they spent teaching parallel programming? I suggest that you say goodmorning to Google. Jerzy Karczmarczuk From ok at cs.otago.ac.nz Wed Dec 17 19:58:56 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Dec 17 19:51:35 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <71DC351C-0412-4B1D-BC83-678E6EFFF9F9@gmail.com> <20081217135740.GA10904@mithrandi.net> Message-ID: <31BCCD1E-7A4F-4C12-8CE3-10310034FA49@cs.otago.ac.nz> [Names removed as a courtesy] > > >> True, true, and who cares about folks afraid of unknown operators >> which >> might do wonderfull stuff ;-))) >> > > That's the kind of mentality I am talking about. The "we are better > than you" mentality, should stay with the Java and .NET people. The subject is a LOGO (abbreviation of LOGOTYPE or LOGOGRAM (a symbol designed to represent an object, concept, or attitude in simple graphic form, as found in road signs, advertising, and so on)) -- OED, paraphrased slightly. Historically, some company symbols have been very complex. Some have used mathematical symbols: many Prolog people will recognise ???, for example, even though none of those symbols is actually used in the language. Egyptian hieroglyphs are clearly recognisable pictures. A Haskell hieroglyph could, for example, be turmeric roots arranged to form a lambda. But wait! "Folks afraid of unknown operators" will be put off by lambdas. To acknowledge that such people *exist* is IN NO WAY to make any claim of superiority. They may be vastly better than us as moral beings, as speakers of many human languages, as singers, in their good looks, in their capacity as parents, in any way you like. The only claim of superiority that can be sustained or even implied is that Haskell programmers are happier with a mathematical approach to programming than say Visual Basic programmers. (I have been known to tell a classroom of students that there are problems for which VB is the right answer, and I was hopping mad when M$oft yanked VBA out of Office for MacOS.) I actually liked the >?= logo when I first saw it; and it wasn't until I saw the version with the different shading in the lambda that I realised that it was lambda on top of >>=. So I can fairly claim to have experienced it in much the same way as someone who had never heard of Haskell before. I liked the look of it, AND I didn't realise that it was a Haskell operator at all. (That's ASCII art for you...) If you know Haskell and you see this logo, it will recall Haskell to you. If you don't know Haskell and you see this logo, it will not suggest anything to you, least of all superiority, BUT it is visually distinctive and memorable. From wqeqweuqy at hotmail.com Wed Dec 17 20:09:33 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Wed Dec 17 20:00:38 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: """ To be eligible, you will need to upload them. Entries not displayed here won't be eligible. """ Do the images really have to be uploaded to the wiki or are external links on the wiki page ok? From ok at cs.otago.ac.nz Wed Dec 17 20:08:44 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Dec 17 20:01:34 2008 Subject: [Haskell-cafe] Please tell me this function exists In-Reply-To: References: Message-ID: <3E77F414-ED07-4E34-B552-AA41AD427D2C@cs.otago.ac.nz> On 18 Dec 2008, at 7:36 am, Brian Hurt wrote: > > I know it's not hard to write, but still: > > concat :: String -> [String] -> String > concat _ [] = "" > concat _ [x] = x > concat sep x:xs = x ++ sep ++ (concat sep xs) > > I've got to be stupid and missing it in the standard libraries. You want concat (intersperse sep strings) using functions from List. From rendel at daimi.au.dk Wed Dec 17 20:36:29 2008 From: rendel at daimi.au.dk (Tillmann Rendel) Date: Wed Dec 17 20:29:50 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49497CB2.2030507@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> Message-ID: <4949A91D.6030504@daimi.au.dk> Hi Andrew, Andrew Coppin wrote: > Technical terms are only > useful to those who already know what they mean, after all. All terms, whether technical or not, are only useful to those who already know what they mean. So if you want to learn new concepts, then you have to learn new terms. All terms are more or less arbitrarily chosen. I don't see why it should be substantially harder to learn arbitrarily chosen greek terms then to learn arbitrarily chosen english terms. > (We don't talk about "single-valued total relations", we talk about > "functions". Because nobody knows what the heck a single-valued total > relation is, but most people immediately "get" what a funtion is.) I strongly disagree for three reasons. First, "function" as we use it in programming is clearly a technical term, which has to be learned by beginners. Second, "function" in Haskell means something else as "function" in, e.g., Java. Third, function is in fact a highly ambiguous technical term, meaning something else in almost every area. In my work, I use at least the following meanings of "function": * a special kind of relation * the purpose or utility of a component in a system * a subroutine in a computer program * the role of a person in an organization * the fact that something is working * a symbol in a signature * one feature of a system which offers several I think "function" is actually an excellent example of an obscure technical term which is hard to understand, which origins from mathematics, which has to be mastered in order to understand Haskell, and which often causes problems for beginners. Therefore, I'm confused why you argue *against* such terms in general, but *for* the term "function". I tend to feel confronted by terms which I happen not yet to understand, while taking the terms I already understand for granted. However, I try to remind myself not to be stunned by mere words, but instead learn about the concepts and their names which are new to me, and teach others some of the concepts and their names which I already know. There is just no point in complaining that one doesn't understand something, and so much more in learning and teaching. Tillmann From wren at freegeek.org Wed Dec 17 21:07:28 2008 From: wren at freegeek.org (wren ng thornton) Date: Wed Dec 17 21:00:04 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <4949B060.7090200@freegeek.org> Jeff Wheeler wrote: > > On Dec 16, 2008, at 10:08 PM, Ryan Grant wrote: > >> nice. >> the first is better. >> in the second, i don't even see the lambda. > > Thanks the feedback. I just uploaded a new version [1] that is > icon-sized, although the font used is Helvetica Neue, which is non-free. > I have no free fonts on my Mac, unfortunately, so it'll stay for the > moment. > > Jeff Wheeler > > [1] http://media.nokrev.com/junk/haskell-logos/logo4.png Another thought would be to have the lower *left* leg of the lambda set off by a different color. Hence something like >,\= Done properly I could see it making the lambda vs. monad alternation more natural. Another suggestion is that the lambda highlighted version (logo1.png) seems a bit top-heavy for the lambda. Moving the centerline up a bit in order to widen the base of the lambda should help that, as well as reducing the militaristic aspect. Of all the versions I've seen, I'd really like some incarnation of this idea to be the new logo. The >\=Haskell one works really well for the named-logo effect, and the simplicity of the five strokes really lets the logo stand on its own as well. It's been a long time since I've done graphic design, so all my tools have rusted. But I could see if some old friends would be interested in taking a whack at it. -- Live well, ~wren From gwern0 at gmail.com Wed Dec 17 21:10:42 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Dec 17 21:03:18 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Wed, Dec 17, 2008 at 8:09 PM, Neal Alexander wrote: > """ To be eligible, you will need to upload them. Entries not displayed here > won't be eligible. """ > > Do the images really have to be uploaded to the wiki or are external links > on the wiki page ok? Uploading to the wiki has the benefit of proving, up front, that you will be cool about licensing your logo entry. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklJsSEACgkQvpDo5Pfl1oLBKgCfdkPFexBX5hlHWooOZSrbrFBg gwwAnRuyPaNjt8rFya1eFcb4Gy3y4XMP =uu2K -----END PGP SIGNATURE----- From dons at galois.com Wed Dec 17 21:25:38 2008 From: dons at galois.com (Don Stewart) Date: Wed Dec 17 21:18:05 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <20081218022538.GA9787@scytale.galois.com> wqeqweuqy: > """ To be eligible, you will need to upload them. Entries not displayed > here won't be eligible. """ > > Do the images really have to be uploaded to the wiki or are external > links on the wiki page ok? > External is fine. Just make sure they're visible on the page. Thanks! - Don From allbery at ece.cmu.edu Wed Dec 17 21:26:38 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Dec 17 21:19:22 2008 Subject: [Haskell-cafe] Implementing PacMan In-Reply-To: <4949718C.70205@btinternet.com> References: <494812DB.8060902@btinternet.com> <49481D34.4050107@cs.nott.ac.uk> <4949718C.70205@btinternet.com> Message-ID: <89D2911E-801E-4A6C-A31B-290A5832E1E7@ece.cmu.edu> On 2008 Dec 17, at 16:39, Andrew Coppin wrote: > So I keep hearing. Unfortunately, discovering what FRP actually > *means* is more or less impossible. I can't find a precise > definition of the term anywhere. There are a small handful That would be because it's still very much an open area of research and nobody's quite sure what it covers. The one-line answer would be "pure transformations of data structures based on passed-in events" --- but that's so general it describes most Haskell programs. One additional part is that it's also a function of time... but time can be just one of the events, or a separate factor. -- 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 ok at cs.otago.ac.nz Wed Dec 17 21:54:09 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Dec 17 21:46:51 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <49497CB2.2030507@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> Message-ID: <6E0A04E0-6B76-4C65-ADE7-5FE68A667A98@cs.otago.ac.nz> On 18 Dec 2008, at 11:26 am, Andrew Coppin wrote: >> (Also, "coroutines"? Seriously? That's hardly an obscure term in >> programming circles.) >> > > Well now, I'm curios. I've been writing computer programs since I > was 9 years old. I hold a diploma *and* an honours degree in > computer science. And I have never even *heard* of a coroutine. To > this day I still don't know what it means. I rather suspect I'm not > the only "programmer" on earth who finds themselves in this > position. ;-) Shame on you for not reading Knuth's "The Art of Computer Programming", Volume 1, "Fundamental Algorithms". The then available three volumes of TAOCP "were named among the best twelve physical-science monographs of the century by American Scientist" "at the end of 1999". (Fasicles 0, 2, 3, and 4 of volume 4 are now available, and parts of fasicle 1 are on-line. Hooray hooray!) Quoting the first two paragraphs of the Wikipedia entry: "In computer science, coroutines are program components that generalize subroutines to allow multiple entry points for suspending and resuming of execution at certain locations. Coroutines are well- suited for implementing more familiar program components such as cooperative tasks, iterators, infinite lists and pipes. The term "coroutine" was originated by Melvin Conway in his seminal 1963 paper.[1]" So "coroutine" has been standard hacker-type programming terminology since 1963. I was able to use coroutines in Burroughs Extended Algol (designed in the mid to late 60s), Simula 67, and Interlisp-D (80s). Current languages supporting them include (thanks, Wikipedia) Lua, Limbo, JavaScript, Python, and Ruby. Since anything with continuations can do coroutines, we add Scheme and SML/NJ. Sather's iterators may be a more familiar form of coroutine. You will commonly find something like a "yield e" statement that reports the value of e to the caller without actually returning, and "resume c" that resumes a coroutine to get the next value. From kevin at ksvanhorn.com Wed Dec 17 23:07:56 2008 From: kevin at ksvanhorn.com (Kevin Van Horn) Date: Wed Dec 17 23:00:32 2008 Subject: [Haskell-cafe] Conditional properties in QuickCheck alter test data generation? References: Message-ID: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> I'm learning QuickCheck, and I'm puzzled by the behavior I'm seeing with conditional properties. After writing and loading a simple qsort function from a separate file, I typed these into ghci: let prop_minimum xs = (length xs > 0) ==> head (qsort xs) == minimum xs where types = xs :: [Integer] let prop_minimum1 xs = (length xs > 3) ==> head (qsort xs) == minimum xs where types = xs :: [Integer] These differ only in that prop_minimum1 uses a more restrictive condition. Then quickCheck prop_minimum outputs "OK, passed 100 tests" but quickCheck prop_minimum1 outputs "Arguments exhausted after 0 tests" Investigating with verboseCheck yields puzzling results. For example, verboseCheck prop_minimum says "OK, passed 100 tests", but some of the test instances it shows have length 0, contrary to the condition... and a significant fraction of the test instances have length > 3, or even length > 10! So why the problem when running quickCheck on prop_minimum1? Running verboseCheck prop_minimum1 just deepens the mystery. Now we see most of the test instances generated having 0 length, and none of them having length > 3. What's going on here? Why is the distribution of generated test instances so drastically altered? BTW, I'm using ghc version 6.10.1, running on Intel Mac OS 10.5.5. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/587ce466/attachment.htm From lambda-belka at yandex.ru Thu Dec 18 01:41:15 2008 From: lambda-belka at yandex.ru (Belka) Date: Thu Dec 18 01:33:51 2008 Subject: [Haskell-cafe] Haskell, successing crossplatform API standart In-Reply-To: <5CDE013B-1F09-48A9-8946-93959E911E52@gmail.com> References: <20742743.post@talk.nabble.com> <5CDE013B-1F09-48A9-8946-93959E911E52@gmail.com> Message-ID: <21067779.post@talk.nabble.com> Thanks for the info! > These days, however, web services seem to be moving towards a RESTful model with a JSON layer and there are plenty of JSON libraries on hackage, which you could just throw over the fastCGI bindings. Oh, but JSON doesn't seem to support tree-structured data... This might turn into hell, when highly demanded in big infrastructures with complex communications. That's why I guess my choise will be XML. Don't know any good alternative with total support on every platform. -- View this message in context: http://www.nabble.com/Haskell%2C-successing-crossplatform-API-standart-tp20742743p21067779.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From lrpalmer at gmail.com Thu Dec 18 01:45:54 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Dec 18 01:38:30 2008 Subject: [Haskell-cafe] Haskell, successing crossplatform API standart In-Reply-To: <21067779.post@talk.nabble.com> References: <20742743.post@talk.nabble.com> <5CDE013B-1F09-48A9-8946-93959E911E52@gmail.com> <21067779.post@talk.nabble.com> Message-ID: <7ca3f0160812172245o58a4591dqe54130b4b302711d@mail.gmail.com> On Wed, Dec 17, 2008 at 11:41 PM, Belka wrote: > > Thanks for the info! > > > These days, however, web services seem to be moving towards a RESTful > model with a JSON layer and there are plenty of JSON libraries on > hackage, which you could just throw over the fastCGI bindings. > > Oh, but JSON doesn't seem to support tree-structured data... Whaaat? You might want to look closer. > This might turn > into hell, when highly demanded in big infrastructures with complex > communications. That's why I guess my choise will be XML. Don't know any > good alternative with total support on every platform. > -- > View this message in context: > http://www.nabble.com/Haskell%2C-successing-crossplatform-API-standart-tp20742743p21067779.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081217/f210d1b1/attachment.htm From cetin.sert at gmail.com Thu Dec 18 02:39:39 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Thu Dec 18 02:32:15 2008 Subject: [Haskell-cafe] lengthOP rewrite rules Message-ID: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> Hi *^o^*, With the following rewrite rules: lengthOP :: (Num a, Ord a) ? Bool ? (a ? a ? Bool) ? [b] ? a ? Bool lengthOP v (?) [] n = 0 ? n lengthOP v (?) xxs n = co xxs 0 where co [] c = c ? n co (_:xs) c | n > c = co xs (c+1) | otherwise = v lenEQ = lengthOP False (==) lenLT = lengthOP False (<) lenLE = lengthOP False (<=) lenGT = lengthOP True (>) lenGE = lengthOP True (>=) {-# RULES -- | length "lenEQ_LHS" forall xs n. (length xs) == n = lenEQ xs n "lenLT_LHS" forall xs n. (length xs) < n = lenLT xs n "lenLE_LHS" forall xs n. (length xs) <= n = lenLE xs n "lenGT_LHS" forall xs n. (length xs) > n = lenGT xs n "lenGE_LHS" forall xs n. (length xs) >= n = lenGE xs n "lenEQ_RHS" forall xs n. n == (length xs) = lenEQ xs n "lenLT_RHS" forall xs n. n < (length xs) = lenGE xs n "lenLE_RHS" forall xs n. n <= (length xs) = lenGT xs n "lenGT_RHS" forall xs n. n > (length xs) = lenLE xs n "lenGE_RHS" forall xs n. n >= (length xs) = lenLT xs n -- | genericLength "glenEQ_LHS" forall xs n. (genericLength xs) == n = lenEQ xs n "glenLT_LHS" forall xs n. (genericLength xs) < n = lenLT xs n "glenLE_LHS" forall xs n. (genericLength xs) <= n = lenLE xs n "glenGT_LHS" forall xs n. (genericLength xs) > n = lenGT xs n "glenGE_LHS" forall xs n. (genericLength xs) >= n = lenGE xs n "glenEQ_RHS" forall xs n. n == (genericLength xs) = lenEQ xs n "glenLT_RHS" forall xs n. n < (genericLength xs) = lenGE xs n "glenLE_RHS" forall xs n. n <= (genericLength xs) = lenGT xs n "glenGT_RHS" forall xs n. n > (genericLength xs) = lenLE xs n "glenGE_RHS" forall xs n. n >= (genericLength xs) = lenLT xs n #-} 1) Is there a way to tell where 'length' is mentioned, what is meant is for example 'Prelude.length' or any length that works on lists? 2) How can I avoid the following error messages? module Main where import Data.List main :: IO Int print $ length (repeat 0) > 200 print $ 200 < length (repeat 0) print $ genericLength (repeat 0) > 200 -- error print $ 200 < genericLength (repeat 0) -- error return 0 ########: Could not deduce (Ord i) from the context (Eq i, Num i) arising from a use of `lenEQ' at ######## Possible fix: add (Ord i) to the context of the RULE "glenEQ_LHS" In the expression: lenEQ xs n When checking the transformation rule "glenEQ_LHS" ########: Could not deduce (Ord a) from the context (Eq a, Num a) arising from a use of `lenEQ' at ######## Possible fix: add (Ord a) to the context of the RULE "glenEQ_RHS" In the expression: lenEQ xs n When checking the transformation rule "glenEQ_RHS" 3) What speaks for/against broad usage of such rewrite rules involving list lengths? Best Regards, Cetin Sert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081218/14ed1e90/attachment.htm From lrpalmer at gmail.com Thu Dec 18 03:02:57 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Dec 18 02:55:33 2008 Subject: [Haskell-cafe] lengthOP rewrite rules In-Reply-To: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> References: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> Message-ID: <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> This does not answer your question, but you can solve this problem without rewrite rules by having length return a lazy natural: data Nat = Zero | Succ Nat And defining lazy comparison operators on it. Of course you cannot replace usages of Prelude.length. But I am really not in favor of rules which change semantics, even if they only make things less strict. My argument is the following. I may come to rely on such nonstrictness as in: bad xs = (length xs > 10, length xs > 20) bad [1..] will return (True,True). However, if I do an obviously semantics-preserving refactor: bad xs = (l > 10, l > 20) where l = length xs My semantics are not preserved: bad [1..] = (_|_, _|_) (if/unless the compiler is clever, in which case my semantics depend on the compiler's cleverness which is even worse) Luke 2008/12/18 Cetin Sert > Hi *^o^*, > > With the following rewrite rules: > > lengthOP :: (Num a, Ord a) ? Bool ? (a ? a ? Bool) ? [b] ? a ? Bool > lengthOP v (?) [] n = 0 ? n > lengthOP v (?) xxs n = co xxs 0 > where > co [] c = c ? n > co (_:xs) c | n > c = co xs (c+1) > | otherwise = v > > lenEQ = lengthOP False (==) > lenLT = lengthOP False (<) > lenLE = lengthOP False (<=) > lenGT = lengthOP True (>) > lenGE = lengthOP True (>=) > > {-# RULES > -- | length > "lenEQ_LHS" forall xs n. (length xs) == n = lenEQ xs n > "lenLT_LHS" forall xs n. (length xs) < n = lenLT xs n > "lenLE_LHS" forall xs n. (length xs) <= n = lenLE xs n > "lenGT_LHS" forall xs n. (length xs) > n = lenGT xs n > "lenGE_LHS" forall xs n. (length xs) >= n = lenGE xs n > > "lenEQ_RHS" forall xs n. n == (length xs) = lenEQ xs n > "lenLT_RHS" forall xs n. n < (length xs) = lenGE xs n > "lenLE_RHS" forall xs n. n <= (length xs) = lenGT xs n > "lenGT_RHS" forall xs n. n > (length xs) = lenLE xs n > "lenGE_RHS" forall xs n. n >= (length xs) = lenLT xs n > > -- | genericLength > "glenEQ_LHS" forall xs n. (genericLength xs) == n = lenEQ xs n > "glenLT_LHS" forall xs n. (genericLength xs) < n = lenLT xs n > "glenLE_LHS" forall xs n. (genericLength xs) <= n = lenLE xs n > "glenGT_LHS" forall xs n. (genericLength xs) > n = lenGT xs n > "glenGE_LHS" forall xs n. (genericLength xs) >= n = lenGE xs n > > "glenEQ_RHS" forall xs n. n == (genericLength xs) = lenEQ xs n > "glenLT_RHS" forall xs n. n < (genericLength xs) = lenGE xs n > "glenLE_RHS" forall xs n. n <= (genericLength xs) = lenGT xs n > "glenGT_RHS" forall xs n. n > (genericLength xs) = lenLE xs n > "glenGE_RHS" forall xs n. n >= (genericLength xs) = lenLT xs n > #-} > > 1) Is there a way to tell where 'length' is mentioned, what is meant is for > example 'Prelude.length' or any length that works on lists? > 2) How can I avoid the following error messages? > > module Main where > import Data.List > main :: IO Int > print $ length (repeat 0) > 200 > print $ 200 < length (repeat 0) > print $ genericLength (repeat 0) > 200 -- error > print $ 200 < genericLength (repeat 0) -- error > return 0 > > ########: > Could not deduce (Ord i) from the context (Eq i, Num i) > arising from a use of `lenEQ' at ######## > Possible fix: add (Ord i) to the context of the RULE "glenEQ_LHS" > In the expression: lenEQ xs n > When checking the transformation rule "glenEQ_LHS" > > ########: > Could not deduce (Ord a) from the context (Eq a, Num a) > arising from a use of `lenEQ' at ######## > Possible fix: add (Ord a) to the context of the RULE "glenEQ_RHS" > In the expression: lenEQ xs n > When checking the transformation rule "glenEQ_RHS" > > 3) What speaks for/against broad usage of such rewrite rules involving list > lengths? > > Best Regards, > Cetin Sert > > _______________________________________________ > 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/20081218/c10b6081/attachment.htm From cetin.sert at gmail.com Thu Dec 18 03:53:04 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Thu Dec 18 03:45:44 2008 Subject: [Haskell-cafe] lengthOP rewrite rules In-Reply-To: <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> References: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> Message-ID: <1ff5dedc0812180053q52d69129n95c3f4aa73208f65@mail.gmail.com> Hi, I tested the following, why does the rewrite rules not fire when using tuples also in testRewrite2, testRewriteReverse2? compiling: rm *.o; ghc -fglasgow-exts -ddump-simpl-stats -O9 --make rules.hs module Main where main :: IO () main = do print $ test 0 print $ test2 0 print $ testRewrite 0 print $ testRewriteReverse 0 print $ testRewrite2 0 print $ testRewriteReverse2 0 test :: a ? Bool test x = pi where f = replicate 2000 x i = repeat x pf = lenGT f 300 pi = lenGT i 300 test2 :: a ? (Bool,Bool) test2 x = (pf,pi) where f = replicate 2000 x i = repeat x pf = lenGT f 300 pi = lenGT i 300 testRewrite :: a ? Bool testRewrite x = pi where f = replicate 2000 x i = repeat x lf = length f li = length i pf = lf > 300 pi = li > 300 testRewriteReverse :: a ? Bool testRewriteReverse x = pi where f = replicate 2000 x i = repeat x lf = length f li = length i pf = 300 <= lf pi = 300 <= li testRewrite2 :: a ? (Bool,Bool) testRewrite2 x = (pf,pi) where f = replicate 2000 x i = repeat x lf = length f li = length i pf = lf > 300 pi = li > 300 testRewriteReverse2 :: a ? (Bool,Bool) testRewriteReverse2 x = (pf,pi) where f = replicate 2000 x i = repeat x lf = length f li = length i pf = 300 <= lf pi = 300 <= li lengthOP :: (Num a, Ord a) ? Bool ? (a ? a ? Bool) ? [b] ? a ? Bool lengthOP v (?) [] n = 0 ? n lengthOP v (?) xxs n = co xxs 0 where co (_:xs) c | n > c = co xs (c+1) | otherwise = v co [] c = c ? n lenEQ = lengthOP False (==) lenLT = lengthOP False (<) lenLE = lengthOP False (<=) lenGT = lengthOP True (>) lenGE = lengthOP True (>=) {-# RULES -- | length "lenEQ_LHS" forall xs n. (length xs) == n = lenEQ xs n "lenLT_LHS" forall xs n. (length xs) < n = lenLT xs n "lenLE_LHS" forall xs n. (length xs) <= n = lenLE xs n "lenGT_LHS" forall xs n. (length xs) > n = lenGT xs n "lenGE_LHS" forall xs n. (length xs) >= n = lenGE xs n "lenEQ_RHS" forall xs n. n == (length xs) = lenEQ xs n "lenLT_RHS" forall xs n. n < (length xs) = lenGE xs n "lenLE_RHS" forall xs n. n <= (length xs) = lenGT xs n "lenGT_RHS" forall xs n. n > (length xs) = lenLE xs n "lenGE_RHS" forall xs n. n >= (length xs) = lenLT xs n #-} Best Regards, Cetin Sert 2008/12/18 Luke Palmer > This does not answer your question, but you can solve this problem without > rewrite rules by having length return a lazy natural: > > data Nat = Zero | Succ Nat > > And defining lazy comparison operators on it. > > Of course you cannot replace usages of Prelude.length. But I am really not > in favor of rules which change semantics, even if they only make things less > strict. My argument is the following. I may come to rely on such > nonstrictness as in: > > bad xs = (length xs > 10, length xs > 20) > > bad [1..] will return (True,True). However, if I do an obviously > semantics-preserving refactor: > > bad xs = (l > 10, l > 20) > where > l = length xs > > My semantics are not preserved: bad [1..] = (_|_, _|_) (if/unless the > compiler is clever, in which case my semantics depend on the compiler's > cleverness which is even worse) > > Luke > > 2008/12/18 Cetin Sert > >> Hi *^o^*, >> >> With the following rewrite rules: >> >> lengthOP :: (Num a, Ord a) ? Bool ? (a ? a ? Bool) ? [b] ? a ? Bool >> lengthOP v (?) [] n = 0 ? n >> lengthOP v (?) xxs n = co xxs 0 >> where >> co [] c = c ? n >> co (_:xs) c | n > c = co xs (c+1) >> | otherwise = v >> >> lenEQ = lengthOP False (==) >> lenLT = lengthOP False (<) >> lenLE = lengthOP False (<=) >> lenGT = lengthOP True (>) >> lenGE = lengthOP True (>=) >> >> {-# RULES >> -- | length >> "lenEQ_LHS" forall xs n. (length xs) == n = lenEQ xs n >> "lenLT_LHS" forall xs n. (length xs) < n = lenLT xs n >> "lenLE_LHS" forall xs n. (length xs) <= n = lenLE xs n >> "lenGT_LHS" forall xs n. (length xs) > n = lenGT xs n >> "lenGE_LHS" forall xs n. (length xs) >= n = lenGE xs n >> >> "lenEQ_RHS" forall xs n. n == (length xs) = lenEQ xs n >> "lenLT_RHS" forall xs n. n < (length xs) = lenGE xs n >> "lenLE_RHS" forall xs n. n <= (length xs) = lenGT xs n >> "lenGT_RHS" forall xs n. n > (length xs) = lenLE xs n >> "lenGE_RHS" forall xs n. n >= (length xs) = lenLT xs n >> >> -- | genericLength >> "glenEQ_LHS" forall xs n. (genericLength xs) == n = lenEQ xs n >> "glenLT_LHS" forall xs n. (genericLength xs) < n = lenLT xs n >> "glenLE_LHS" forall xs n. (genericLength xs) <= n = lenLE xs n >> "glenGT_LHS" forall xs n. (genericLength xs) > n = lenGT xs n >> "glenGE_LHS" forall xs n. (genericLength xs) >= n = lenGE xs n >> >> "glenEQ_RHS" forall xs n. n == (genericLength xs) = lenEQ xs n >> "glenLT_RHS" forall xs n. n < (genericLength xs) = lenGE xs n >> "glenLE_RHS" forall xs n. n <= (genericLength xs) = lenGT xs n >> "glenGT_RHS" forall xs n. n > (genericLength xs) = lenLE xs n >> "glenGE_RHS" forall xs n. n >= (genericLength xs) = lenLT xs n >> #-} >> >> 1) Is there a way to tell where 'length' is mentioned, what is meant is >> for example 'Prelude.length' or any length that works on lists? >> 2) How can I avoid the following error messages? >> >> module Main where >> import Data.List >> main :: IO Int >> print $ length (repeat 0) > 200 >> print $ 200 < length (repeat 0) >> print $ genericLength (repeat 0) > 200 -- error >> print $ 200 < genericLength (repeat 0) -- error >> return 0 >> >> ########: >> Could not deduce (Ord i) from the context (Eq i, Num i) >> arising from a use of `lenEQ' at ######## >> Possible fix: add (Ord i) to the context of the RULE "glenEQ_LHS" >> In the expression: lenEQ xs n >> When checking the transformation rule "glenEQ_LHS" >> >> ########: >> Could not deduce (Ord a) from the context (Eq a, Num a) >> arising from a use of `lenEQ' at ######## >> Possible fix: add (Ord a) to the context of the RULE "glenEQ_RHS" >> In the expression: lenEQ xs n >> When checking the transformation rule "glenEQ_RHS" >> >> 3) What speaks for/against broad usage of such rewrite rules involving >> list lengths? >> >> Best Regards, >> Cetin Sert >> >> _______________________________________________ >> 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/20081218/60f81a6e/attachment-0001.htm From ketil at malde.org Thu Dec 18 03:57:51 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Dec 18 03:50:27 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <1229547312.1787.6.camel@porges-laptop> (George Pollard's message of "Thu\, 18 Dec 2008 09\:55\:12 +1300") References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <49496519.5010409@van.steenbergen.nl> <1229547312.1787.6.camel@porges-laptop> Message-ID: <87myetdfn4.fsf@malde.org> George Pollard writes: > Might be interesting to try angling the ends of the stems to look > something more like the guillemot in [1]. I might try this in Gimp but > I'm no designer :P If you're on Linux or similar, I recommend Inkscape for this kind of thing. -k -- If I haven't seen further, it is by standing in the footprints of giants From ndmitchell at gmail.com Thu Dec 18 04:02:21 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Dec 18 03:54:56 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <87myetdfn4.fsf@malde.org> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <49496519.5010409@van.steenbergen.nl> <1229547312.1787.6.camel@porges-laptop> <87myetdfn4.fsf@malde.org> Message-ID: <404396ef0812180102m6b338147j60c1caacad3d04cc@mail.gmail.com> Hi >> Might be interesting to try angling the ends of the stems to look >> something more like the guillemot in [1]. I might try this in Gimp but >> I'm no designer :P > > If you're on Linux or similar, I recommend Inkscape for this kind of > thing. If you're on Windows, Inkscape also works well for most graphics tasks (unless you bought a copy of Xara X, in which case use that unless you want SVG output) Thanks Neil From cetin.sert at gmail.com Thu Dec 18 04:11:36 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Thu Dec 18 04:04:12 2008 Subject: [Haskell-cafe] lengthOP rewrite rules In-Reply-To: <1ff5dedc0812180053q52d69129n95c3f4aa73208f65@mail.gmail.com> References: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> <1ff5dedc0812180053q52d69129n95c3f4aa73208f65@mail.gmail.com> Message-ID: <1ff5dedc0812180111v578ca7abn48ee15d5c2336a0f@mail.gmail.com> oh, btw I am using GHC 6.10.1 (on Linux x86_64) 2008/12/18 Cetin Sert > Hi, > > I tested the following, why does the rewrite rules not fire when using > tuples also in testRewrite2, testRewriteReverse2? compiling: rm *.o; ghc > -fglasgow-exts -ddump-simpl-stats -O9 --make rules.hs > > module Main where > > main :: IO () > main = do > print $ test 0 > print $ test2 0 > print $ testRewrite 0 > print $ testRewriteReverse 0 > print $ testRewrite2 0 > print $ testRewriteReverse2 0 > > test :: a ? Bool > test x = pi > where > f = replicate 2000 x > i = repeat x > pf = lenGT f 300 > pi = lenGT i 300 > > test2 :: a ? (Bool,Bool) > test2 x = (pf,pi) > where > f = replicate 2000 x > i = repeat x > pf = lenGT f 300 > pi = lenGT i 300 > > testRewrite :: a ? Bool > testRewrite x = pi > where > f = replicate 2000 x > i = repeat x > lf = length f > li = length i > pf = lf > 300 > pi = li > 300 > > testRewriteReverse :: a ? Bool > testRewriteReverse x = pi > where > f = replicate 2000 x > i = repeat x > lf = length f > li = length i > pf = 300 <= lf > pi = 300 <= li > > testRewrite2 :: a ? (Bool,Bool) > testRewrite2 x = (pf,pi) > where > f = replicate 2000 x > i = repeat x > lf = length f > li = length i > pf = lf > 300 > pi = li > 300 > > testRewriteReverse2 :: a ? (Bool,Bool) > testRewriteReverse2 x = (pf,pi) > where > f = replicate 2000 x > i = repeat x > lf = length f > li = length i > pf = 300 <= lf > pi = 300 <= li > > > lengthOP :: (Num a, Ord a) ? Bool ? (a ? a ? Bool) ? [b] ? a ? Bool > lengthOP v (?) [] n = 0 ? n > lengthOP v (?) xxs n = co xxs 0 > where > co (_:xs) c | n > c = co xs (c+1) > | otherwise = v > co [] c = c ? n > > lenEQ = lengthOP False (==) > lenLT = lengthOP False (<) > lenLE = lengthOP False (<=) > lenGT = lengthOP True (>) > lenGE = lengthOP True (>=) > > {-# RULES > -- | length > "lenEQ_LHS" forall xs n. (length xs) == n = lenEQ xs n > "lenLT_LHS" forall xs n. (length xs) < n = lenLT xs n > "lenLE_LHS" forall xs n. (length xs) <= n = lenLE xs n > "lenGT_LHS" forall xs n. (length xs) > n = lenGT xs n > "lenGE_LHS" forall xs n. (length xs) >= n = lenGE xs n > > "lenEQ_RHS" forall xs n. n == (length xs) = lenEQ xs n > "lenLT_RHS" forall xs n. n < (length xs) = lenGE xs n > "lenLE_RHS" forall xs n. n <= (length xs) = lenGT xs n > "lenGT_RHS" forall xs n. n > (length xs) = lenLE xs n > "lenGE_RHS" forall xs n. n >= (length xs) = lenLT xs n > #-} > > Best Regards, > Cetin Sert > > 2008/12/18 Luke Palmer > >> This does not answer your question, but you can solve this problem without >> rewrite rules by having length return a lazy natural: >> >> >> data Nat = Zero | Succ Nat >> >> And defining lazy comparison operators on it. >> >> Of course you cannot replace usages of Prelude.length. But I am really >> not in favor of rules which change semantics, even if they only make things >> less strict. My argument is the following. I may come to rely on such >> nonstrictness as in: >> >> bad xs = (length xs > 10, length xs > 20) >> >> bad [1..] will return (True,True). However, if I do an obviously >> semantics-preserving refactor: >> >> bad xs = (l > 10, l > 20) >> where >> l = length xs >> >> My semantics are not preserved: bad [1..] = (_|_, _|_) (if/unless the >> compiler is clever, in which case my semantics depend on the compiler's >> cleverness which is even worse) >> >> Luke >> >> 2008/12/18 Cetin Sert >> >>> Hi *^o^*, >>> >>> With the following rewrite rules: >>> >>> lengthOP :: (Num a, Ord a) ? Bool ? (a ? a ? Bool) ? [b] ? a ? Bool >>> lengthOP v (?) [] n = 0 ? n >>> lengthOP v (?) xxs n = co xxs 0 >>> where >>> co [] c = c ? n >>> co (_:xs) c | n > c = co xs (c+1) >>> | otherwise = v >>> >>> lenEQ = lengthOP False (==) >>> lenLT = lengthOP False (<) >>> lenLE = lengthOP False (<=) >>> lenGT = lengthOP True (>) >>> lenGE = lengthOP True (>=) >>> >>> {-# RULES >>> -- | length >>> "lenEQ_LHS" forall xs n. (length xs) == n = lenEQ xs n >>> "lenLT_LHS" forall xs n. (length xs) < n = lenLT xs n >>> "lenLE_LHS" forall xs n. (length xs) <= n = lenLE xs n >>> "lenGT_LHS" forall xs n. (length xs) > n = lenGT xs n >>> "lenGE_LHS" forall xs n. (length xs) >= n = lenGE xs n >>> >>> "lenEQ_RHS" forall xs n. n == (length xs) = lenEQ xs n >>> "lenLT_RHS" forall xs n. n < (length xs) = lenGE xs n >>> "lenLE_RHS" forall xs n. n <= (length xs) = lenGT xs n >>> "lenGT_RHS" forall xs n. n > (length xs) = lenLE xs n >>> "lenGE_RHS" forall xs n. n >= (length xs) = lenLT xs n >>> >>> -- | genericLength >>> "glenEQ_LHS" forall xs n. (genericLength xs) == n = lenEQ xs n >>> "glenLT_LHS" forall xs n. (genericLength xs) < n = lenLT xs n >>> "glenLE_LHS" forall xs n. (genericLength xs) <= n = lenLE xs n >>> "glenGT_LHS" forall xs n. (genericLength xs) > n = lenGT xs n >>> "glenGE_LHS" forall xs n. (genericLength xs) >= n = lenGE xs n >>> >>> "glenEQ_RHS" forall xs n. n == (genericLength xs) = lenEQ xs n >>> "glenLT_RHS" forall xs n. n < (genericLength xs) = lenGE xs n >>> "glenLE_RHS" forall xs n. n <= (genericLength xs) = lenGT xs n >>> "glenGT_RHS" forall xs n. n > (genericLength xs) = lenLE xs n >>> "glenGE_RHS" forall xs n. n >= (genericLength xs) = lenLT xs n >>> #-} >>> >>> 1) Is there a way to tell where 'length' is mentioned, what is meant is >>> for example 'Prelude.length' or any length that works on lists? >>> 2) How can I avoid the following error messages? >>> >>> module Main where >>> import Data.List >>> main :: IO Int >>> print $ length (repeat 0) > 200 >>> print $ 200 < length (repeat 0) >>> print $ genericLength (repeat 0) > 200 -- error >>> print $ 200 < genericLength (repeat 0) -- error >>> return 0 >>> >>> ########: >>> Could not deduce (Ord i) from the context (Eq i, Num i) >>> arising from a use of `lenEQ' at ######## >>> Possible fix: add (Ord i) to the context of the RULE "glenEQ_LHS" >>> In the expression: lenEQ xs n >>> When checking the transformation rule "glenEQ_LHS" >>> >>> ########: >>> Could not deduce (Ord a) from the context (Eq a, Num a) >>> arising from a use of `lenEQ' at ######## >>> Possible fix: add (Ord a) to the context of the RULE "glenEQ_RHS" >>> In the expression: lenEQ xs n >>> When checking the transformation rule "glenEQ_RHS" >>> >>> 3) What speaks for/against broad usage of such rewrite rules involving >>> list lengths? >>> >>> Best Regards, >>> Cetin Sert >>> >>> _______________________________________________ >>> 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/20081218/5b99c0fc/attachment.htm From lrpalmer at gmail.com Thu Dec 18 04:18:33 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Dec 18 04:11:09 2008 Subject: [Haskell-cafe] lengthOP rewrite rules In-Reply-To: <1ff5dedc0812180053q52d69129n95c3f4aa73208f65@mail.gmail.com> References: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> <1ff5dedc0812180053q52d69129n95c3f4aa73208f65@mail.gmail.com> Message-ID: <7ca3f0160812180118m14c2ba9ar9033535daa408ea0@mail.gmail.com> On Thu, Dec 18, 2008 at 1:53 AM, Cetin Sert wrote: > > Hi, > > I tested the following, why does the rewrite rules not fire when using tuples also in testRewrite2, testRewriteReverse2? testRewrite2 :: a ? (Bool,Bool) > testRewrite2 x = (pf,pi) > where > f = replicate 2000 x > i = repeat x > lf = length f > li = length i > pf = lf > 300 > pi = li > 300 > > Why would you expect it to? The compiler is free to inline lf and li to discover that the rule applies, but it is also free not to. Applying all applicable rules while maintaining the ability to abstract is undecidable (big surprise). Thus the dependency on compiler cleverness I mentioned... There might be something you can do with rule ordering, make sure it happens after the inlining phase, but I don't know how to do that offhand. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081218/34b599a0/attachment.htm From v.dijk.bas at gmail.com Thu Dec 18 04:24:31 2008 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Dec 18 04:17:06 2008 Subject: [Haskell-cafe] How to choose an arbitrary Arbitrary? In-Reply-To: <2f9b2d30812171405y43599168p9e077c291068d01e@mail.gmail.com> References: <2f9b2d30812171405y43599168p9e077c291068d01e@mail.gmail.com> Message-ID: On Wed, Dec 17, 2008 at 11:05 PM, Ryan Ingram wrote: > ...It's possible to extend this idea and generate an "arbitrary arbitrary"... Thanks for your thorough answer. I like the SomeArbitrary idea. I see it's easy to also sample[1] SomeArbitrary. You do need to add a 'Show' constraint to the existential 'a' in SomeArbitrary. samplesSomeArbitrary :: IO () samplesSomeArbitrary = mapM_ f =<< sample' arbitrary where f (SomeArbitrary a) = sample (arbitrary `asTypeOf` gen a) where gen :: a -> Gen a gen _ = undefined Thanks, Bas [1] sample: http://hackage.haskell.org/packages/archive/QuickCheck/2.1.0.1/doc/html/Test-QuickCheck.html#v%3Asample From ryani.spam at gmail.com Thu Dec 18 04:37:41 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 18 04:30:15 2008 Subject: [Haskell-cafe] Coroutines Message-ID: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> Andrew was recently asking about co-routines. A couple of years ago, I was in much the same position as him; although I am pretty sure I had heard the term before, it seemed like a mysterious idea with no practical use. Then I learned Ruby. Ruby makes extensive use of coroutines; it's not uncommon to have three or more coroutines executing cooperatively, made simple by how easy it is to pass blocks of code around in that language. The entire collection iteration system in Ruby is based on coroutines; if an object implements "each", it can be iterated over: [1, 2, 3].each { |x| print x } Implementing "each" for a container is generally simple; you just write a loop and call "yield" def each [1 .. length].each { |index| yield self[index] } end It surprised me how simple and powerful this concept was; code that previously was incredibly ugly to write became simple. I think this abstraction is one of the big reasons for Ruby's current success. At the Haskell Symposium this year, Jesse Tov gave a talk about Session Types in Haskell, and it struck me that they are ideal for implementing coroutines in a type-safe manner. Here you can write pure functions that represent a communicating routines, and guarantee that the communication completes successfully (assuming the routines terminate, of course). Consider these two values: f1 :: Int -> (Char, ()) f2 :: (Int, Char -> String) You can see a natural way to connect them, using the duality of (a, _) and (a -> _): connect_f1f2 :: ((), String) connect_f1f2 = let (arg1, k2) = f2 (arg2, result1) = f1 arg1 result2 = k2 arg2 in (result1, result2) I implemented this idea, along with a nice syntax for these coroutines, in http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Coroutine-0.1.0.0: f1 :: InSession (Int :?: Char :!: Eps) () f1 = runSession $ do x <- get put (head $ show x) return () f2 :: InSession (Int :!: Char :?: Eps) String f2 = runSession $ do put 6 result <- get return ("the answer is " ++ [result]) (Caveat: while this uses the do-notation, it's not *exactly* a monad; it's something more general than that. See Control.Monad.Indexed for the details. Thanks to the GHC team for NoImplicitPrelude!) You can then add choice, looping constructs, etc., to allow increasingly complicated protocols: peer1 :: InSession ((Int :?: Int :!: Eps) :?* Eps) Int -- read an Int, then write an Int, any number of times we are told to do so -- then return an Int peer2 :: InSession ((Int :!: Int :?: Eps) :!* Eps) [Int] -- write an Int, then read an Int, any number of times we want -- then return a list of Ints. The neat thing about this library is that the communication is completely pure! No side effects required! ghci> :t connect peer1 peer2 connect peer1 peer2 :: (Int, [Int]) -- ryan On Wed, Dec 17, 2008 at 6:54 PM, Richard O'Keefe wrote: > On 18 Dec 2008, at 11:26 am, Andrew Coppin wrote: >>> >>> (Also, "coroutines"? Seriously? That's hardly an obscure term in >>> programming circles.) >>> >> >> Well now, I'm curios. I've been writing computer programs since I was 9 >> years old. I hold a diploma *and* an honours degree in computer science. And >> I have never even *heard* of a coroutine. To this day I still don't know >> what it means. I rather suspect I'm not the only "programmer" on earth who >> finds themselves in this position. ;-) > > Shame on you for not reading Knuth's > "The Art of Computer Programming", Volume 1, "Fundamental Algorithms". > The then available three volumes of TAOCP > "were named among the best twelve physical-science monographs > of the century by American Scientist" "at the end of 1999". > (Fasicles 0, 2, 3, and 4 of volume 4 are now available, and > parts of fasicle 1 are on-line. Hooray hooray!) > > Quoting the first two paragraphs of the Wikipedia entry: > "In computer science, coroutines are program components that generalize > subroutines to allow multiple entry points for suspending and resuming of > execution at certain locations. Coroutines are well-suited for implementing > more familiar program components such as cooperative tasks, iterators, > infinite lists and pipes. > The term "coroutine" was originated by Melvin Conway in his seminal 1963 > paper.[1]" > > So "coroutine" has been standard hacker-type programming terminology > since 1963. I was able to use coroutines in Burroughs Extended Algol > (designed in the mid to late 60s), Simula 67, and Interlisp-D (80s). > Current languages supporting them include (thanks, Wikipedia) Lua, > Limbo, JavaScript, Python, and Ruby. Since anything with continuations > can do coroutines, we add Scheme and SML/NJ. Sather's iterators may be > a more familiar form of coroutine. You will commonly find something > like a "yield e" statement that reports the value of e to the caller > without actually returning, and "resume c" that resumes a coroutine > to get the next value. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Thu Dec 18 04:49:06 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 18 04:41:40 2008 Subject: [Haskell-cafe] lengthOP rewrite rules In-Reply-To: <7ca3f0160812180118m14c2ba9ar9033535daa408ea0@mail.gmail.com> References: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> <1ff5dedc0812180053q52d69129n95c3f4aa73208f65@mail.gmail.com> <7ca3f0160812180118m14c2ba9ar9033535daa408ea0@mail.gmail.com> Message-ID: <2f9b2d30812180149r810590byb80e1af8b0349ae0@mail.gmail.com> 2008/12/18 Luke Palmer : > On Thu, Dec 18, 2008 at 1:53 AM, Cetin Sert wrote: >> >> Hi, >> >> I tested the following, why does the rewrite rules not fire when using >> tuples also in testRewrite2, testRewriteReverse2? > >> testRewrite2 :: a ? (Bool,Bool) >> testRewrite2 x = (pf,pi) >> where >> f = replicate 2000 x >> i = repeat x >> lf = length f >> li = length i >> pf = lf > 300 >> pi = li > 300 >> > > Why would you expect it to? The compiler is free to inline lf and li to > discover that the rule applies, but it is also free not to. Applying all > applicable rules while maintaining the ability to abstract is undecidable > (big surprise). Thus the dependency on compiler cleverness I mentioned... I'm agreeing with Luke here. It's possible that the compiler decided to inline f and i, and length, and determined that lf == 2000 and li == _|_ Or it could have decided not to inline at all. Or some other possibility. If you specify {-# INLINE lf #-}, do the results change? I suspect they might. -- ryan From marlowsd at gmail.com Thu Dec 18 04:57:41 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Dec 18 04:50:19 2008 Subject: [Haskell-cafe] Re: excessive usage of CPU by threadDelay in GHCi In-Reply-To: <87ej0723sx.wl%jeremy@n-heptane.com> References: <87ej0723sx.wl%jeremy@n-heptane.com> Message-ID: <494A1E95.3030505@gmail.com> Jeremy Shaw wrote: > I have the following simple program: > > import Control.Concurrent > main = threadDelay (10^6) >> main > > If I run it in GHCi it requires 2-5% of my CPU. If i compile it, it > takes 0% of my CPU. It does not matter if I compile -O0, -O2, > -threaded, it always uses 0% (which is good). > > Is it expected that threadDelay should be really expensive in GHCi? Am > I doing something wrong? Or should I file a bug? Please file a bug. It could be that the idle time GC is running repeatedly rather than just once, or something like that. Cheers, Simon From ryani.spam at gmail.com Thu Dec 18 05:26:26 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 18 05:19:01 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <1229594097-sup-463@ausone.local> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> Message-ID: <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> On Thu, Dec 18, 2008 at 2:00 AM, Nicolas Pouillard wrote: > I don't see why one would need session types, channels... to express that. > I maybe need a more complicated coroutines (ruby) example that would require > using this system. OK, how would you type these routines in Haskell? def simple yield "hello" yield 1 yield (lambda { |x| x + 1 }) end def useSimple state = 0 result = nil simple { |x| if (state == 0) then result = x else if (state == 1) then result += (x * 4).toString else if (state == 2) then result += x.call(10).toString state = state + 1 } result end I know it's a bit contrived, but you get the idea. In Haskell using Control.Coroutine: simple :: forall rest. Session (String :!: Int :!: (Int -> Int) :!: rest) rest () simple = do put "hello" put 1 put (\x -> x + 1) useSimple :: forall rest. Session (String :?: Int :?: (Int -> Int) :?: rest) rest String useSimple = do string <- get int <- get func <- get return (string ++ show (int * 4) ++ show (func 10)) result :: String result = snd $ connects simple useSimple -- result = "hello411" From miguelimo38 at yandex.ru Thu Dec 18 05:42:21 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Dec 18 05:35:18 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> Message-ID: <63D2ECC4-C48D-46F7-91AE-9CE05240381B@yandex.ru> First thing I've tried when learning Ruby was something like that: ================ def a yield {puts 1} end a {yield} ================ It didn't work. Can Coroutine.hs do something like that? On 18 Dec 2008, at 13:26, Ryan Ingram wrote: > On Thu, Dec 18, 2008 at 2:00 AM, Nicolas Pouillard > wrote: >> I don't see why one would need session types, channels... to >> express that. >> I maybe need a more complicated coroutines (ruby) example that >> would require >> using this system. > > OK, how would you type these routines in Haskell? > > def simple > yield "hello" > yield 1 > yield (lambda { |x| x + 1 }) > end > > def useSimple > state = 0 > result = nil > simple { |x| > if (state == 0) then result = x > else if (state == 1) then result += (x * 4).toString > else if (state == 2) then result += x.call(10).toString > state = state + 1 > } > result > end > > I know it's a bit contrived, but you get the idea. > > In Haskell using Control.Coroutine: > > simple :: forall rest. Session (String :!: Int :!: (Int -> Int) :!: > rest) rest () > simple = do > put "hello" > put 1 > put (\x -> x + 1) > > useSimple :: forall rest. Session (String :?: Int :?: (Int -> Int) :?: > rest) rest String > useSimple = do > string <- get > int <- get > func <- get > return (string ++ show (int * 4) ++ show (func 10)) > > result :: String > result = snd $ connects simple useSimple > -- result = "hello411" > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bulat.ziganshin at gmail.com Thu Dec 18 05:47:11 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Dec 18 05:40:04 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <63D2ECC4-C48D-46F7-91AE-9CE05240381B@yandex.ru> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> <63D2ECC4-C48D-46F7-91AE-9CE05240381B@yandex.ru> Message-ID: <1153550968.20081218134711@gmail.com> Hello Miguel, Thursday, December 18, 2008, 1:42:21 PM, you wrote: ruby doesn't support coroutines, but only iterators (where control moved from caller to callee). usually control is on the caller side, and coroutines gives control to both (or many) sides coroutines are easily emulated in IO monad using multithreading, and i think that are easily emulated both in Ruby and Haskell using callCC > First thing I've tried when learning Ruby was something like that: > ================ > def a > yield {puts 1} > end > a {yield} > ================ > It didn't work. Can Coroutine.hs do something like that? > On 18 Dec 2008, at 13:26, Ryan Ingram wrote: >> On Thu, Dec 18, 2008 at 2:00 AM, Nicolas Pouillard >> wrote: >>> I don't see why one would need session types, channels... to >>> express that. >>> I maybe need a more complicated coroutines (ruby) example that >>> would require >>> using this system. >> >> OK, how would you type these routines in Haskell? >> >> def simple >> yield "hello" >> yield 1 >> yield (lambda { |x| x + 1 }) >> end >> >> def useSimple >> state = 0 >> result = nil >> simple { |x| >> if (state == 0) then result = x >> else if (state == 1) then result += (x * 4).toString >> else if (state == 2) then result += x.call(10).toString >> state = state + 1 >> } >> result >> end >> >> I know it's a bit contrived, but you get the idea. >> >> In Haskell using Control.Coroutine: >> >> simple :: forall rest. Session (String :!: Int :!: (Int -> Int) :!: >> rest) rest () >> simple = do >> put "hello" >> put 1 >> put (\x -> x + 1) >> >> useSimple :: forall rest. Session (String :?: Int :?: (Int -> Int) :?: >> rest) rest String >> useSimple = do >> string <- get >> int <- get >> func <- get >> return (string ++ show (int * 4) ++ show (func 10)) >> >> result :: String >> result = snd $ connects simple useSimple >> -- result = "hello411" >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From greenrd at greenrd.org Thu Dec 18 06:01:42 2008 From: greenrd at greenrd.org (Robin Green) Date: Thu Dec 18 05:54:37 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> Message-ID: <20081218110142.215be11f@greenrd.org> In my opinion, in Haskell, you don't need coroutines because you have lazy evaluation. You example below is simply an example of a heterogenous list being read. The simplest way to implement a heterogenous list in Haskell is to use a tuple. Or you could use the HList package. -- Robin On Thu, 18 Dec 2008 02:26:26 -0800 "Ryan Ingram" wrote: > On Thu, Dec 18, 2008 at 2:00 AM, Nicolas Pouillard > wrote: > > I don't see why one would need session types, channels... to > > express that. I maybe need a more complicated coroutines (ruby) > > example that would require using this system. > > OK, how would you type these routines in Haskell? > > def simple > yield "hello" > yield 1 > yield (lambda { |x| x + 1 }) > end > > def useSimple > state = 0 > result = nil > simple { |x| > if (state == 0) then result = x > else if (state == 1) then result += (x * 4).toString > else if (state == 2) then result += x.call(10).toString > state = state + 1 > } > result > end > > I know it's a bit contrived, but you get the idea. > > In Haskell using Control.Coroutine: > > simple :: forall rest. Session (String :!: Int :!: (Int -> Int) :!: > rest) rest () > simple = do > put "hello" > put 1 > put (\x -> x + 1) > > useSimple :: forall rest. Session (String :?: Int :?: (Int -> Int) :?: > rest) rest String > useSimple = do > string <- get > int <- get > func <- get > return (string ++ show (int * 4) ++ show (func 10)) > > result :: String > result = snd $ connects simple useSimple > -- result = "hello411" > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From briqueabraque at yahoo.com Thu Dec 18 06:27:24 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Thu Dec 18 06:20:10 2008 Subject: [Haskell-cafe] Detecting system endianness Message-ID: Hi, Is there some way I can check the endianness of the machine my haskell code is running in? Thanks, Maur?cio From ryani.spam at gmail.com Thu Dec 18 07:22:21 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 18 07:14:57 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <20081218110142.215be11f@greenrd.org> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> <20081218110142.215be11f@greenrd.org> Message-ID: <2f9b2d30812180422l5f56c675k515f0880922006e0@mail.gmail.com> On Thu, Dec 18, 2008 at 3:01 AM, Robin Green wrote: > In my opinion, in Haskell, you don't need coroutines because you have > lazy evaluation. That's a fair criticism. Lazy evaluation basically gives you a coroutine embedded in any data structure. But sometimes making implicit things explicit aids understanding! Especially when there can be communication in both directions; that is, the data structure can be somewhat dependent on the code doing the evaluation. In addition, I think coroutines under effectful monads are still potentially useful. It would not be too hard to extend this library to allow effectful computations to communicate. At the very least I can easily imagine a version of InSession that supports lifting from IO into coroutines. > You example below is simply an example of a heterogenous list being > read. The simplest way to implement a heterogenous list in Haskell is > to use a tuple. Or you could use the HList package. Actually, the result of "runSession simple" is isomorphic to a tuple/heterogeneous list: > data instance InSession (a :!: r) v = W a (InSession r v) > newtype instance InSession Eps v = Eps v runSession simple :: InSession (String :!: Int :!: (Int -> Int) :!: Eps) () => W "hello" $ W 1 $ W (+1) $ Eps () Similarily, useSimple evaluates to a function of three arguments: > newtype instance InSession (a :?: r) v = R (a -> InSession r v) runSession useSimple => R $ \string -> R $ \int -> R $ \func -> Eps (string ++ show (int * 4) ++ show (func 10)) There are three pieces to this package: 1) A monad-like structure that gives nice syntax for the construction of InSession values. 2) A data family that gives a representation of these values as different functors. This is similar to using the TypeCompose library [1] and the (,) a and (->) a Functor instances [2]. That is, in some way (a :!: r) represents ((,) a) . r. (.) here represents function composition at the *type* level. This allows composition of functors: (a :!: b :?: c :!: Eps) == (a,) . (b ->) . (c,) . Id == \v -> (a, b -> (c,v)) where again, the lambda is at the type level, and (a,) means a section at the type level similar to (5 <=) at the value level. (As an aside, my thanks to Simon Peyton-Jones for suggesting this representation of sessions using type families.) 3) A "duality" type family and connector which shows which functors can be connected to which other functors. This is similar to the "zap" operation in Category-extras [3]. I wrote the library initially to play around with (1); Indexed monads are an interesting topic and I don't think they are well covered outside of the dense material by Oleg & friends. I definitely understand them much better after writing it! (2) and (3) are there to give some structure to the exercise. The other goal was to give a machine-checkable proof of the semantics of session types described in Jesse Tov's paper [4]. In the paper, sessions are represented by effectful computations, which run in parallel and communicate over *untyped* channels, using unsafeCoerce. The paper contains a proof that this is indeed safe, but it seemed worthwhile to encode the proof in the Haskell type system, allowing the possibility to remove unsafeCoerce. -- ryan [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/TypeCompose-0.6.3 [2] http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad-Instances.html [3] http://comonad.com/reader/2008/zapping-strong-adjunctions/ [4] http://www.ccs.neu.edu/home/tov/pubs/session08.html From ryani.spam at gmail.com Thu Dec 18 07:33:22 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 18 07:25:56 2008 Subject: [Haskell-cafe] Detecting system endianness In-Reply-To: References: Message-ID: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> I think something like this might work: Prelude GHC.Exts GHC.Word> let W64# x = 0x100000002 in W32# (unsafeCoerce# x) 2 You should get 1 for big-endian and 2 for little-endian. (Disclaimer: not particularily well-tested.) -- ryan On Thu, Dec 18, 2008 at 3:27 AM, Mauricio wrote: > Hi, > > Is there some way I can check the endianness > of the machine my haskell code is running in? > > Thanks, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Thu Dec 18 07:40:47 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Dec 18 07:33:22 2008 Subject: [Haskell-cafe] Detecting system endianness In-Reply-To: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> Message-ID: <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> Actually, this is probably safer: import Foreign.Marshal.Alloc import Foreign.Ptr import Foreign.Storable import Data.Word import System.IO.Unsafe endianCheck = unsafePerformIO $ alloca $ \p -> poke p (0x01020304 :: Word32) >> peek (castPtr p :: Ptr Word8) littleEndian = endianCheck == 4 bigEndian = endianCheck == 1 -- ryan On Thu, Dec 18, 2008 at 4:33 AM, Ryan Ingram wrote: > I think something like this might work: > > Prelude GHC.Exts GHC.Word> let W64# x = 0x100000002 in W32# (unsafeCoerce# x) > 2 > > You should get 1 for big-endian and 2 for little-endian. > > (Disclaimer: not particularily well-tested.) > > -- ryan > > On Thu, Dec 18, 2008 at 3:27 AM, Mauricio wrote: >> Hi, >> >> Is there some way I can check the endianness >> of the machine my haskell code is running in? >> >> Thanks, >> Maur?cio >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From stefan at endrullis.de Thu Dec 18 07:45:58 2008 From: stefan at endrullis.de (Stefan Endrullis) Date: Thu Dec 18 07:38:40 2008 Subject: [Haskell-cafe] Functional MetaPost in 5 Steps Message-ID: <21070707.post@talk.nabble.com> I have the same problem with FuncMP. I've also replaced the "generate" function by a custom "toMPFile" as you suggested, but mpost still generates only an empty white sheet. I've used the simple example posted in the first message of this thread. The generated .mp file is also relatively simple (see attachment http://www.nabble.com/file/p21070707/Test.mp Test.mp ) The only problem is the line "input FuncMP", which produces additional code in the ps file and causes the white page. If you remove this line everything is fine again and you can see the text "blah". Here's the additional code FuncMP produces in the .ps file: ----------------------------------------------------------------- /xdvi$run where {pop errordict begin /undefined {} bind def end} if /fmp1 /fmp1 def /fmp8 /fmp8 def /fmp24 /fmp24 def /bitline1 {gsave pop dup scale dup length 8 mul 1 true currentpoint translate [66.66666 0 0 66.66666 0 0] 4 index imagemask pop grestore} bind def /bitline8 {gsave pop dup scale dup length 1 8 currentpoint translate [2.8 0 0 2.8 0 0] 4 index image pop grestore} bind def /bitline24 {gsave pop dup scale dup length 3 idiv 1 8 currentpoint translate [2.777777 0 0 2.777777 0 0] 4 index false 3 colorimage pop grestore} bind def /XDVIfshow {findfont exch scalefont setfont show} bind def /DVIPSfshow {exch gsave 72 TeXDict /Resolution get div -72 TeXDict /VResolution get div scale 1 DVImag div dup scale get cvx exec show grestore} bind def /fshowText {/xdvi$run where {pop XDVIfshow} {DVIPSfshow} ifelse} def /fshow { exch dup /fmp1 eq {bitline1} {dup /fmp8 eq {bitline8} {dup /fmp24 eq {bitline24} {fshowText} ifelse} ifelse} ifelse} def ----------------------------------------------------------------- You can also fix the .ps file by removing the "/fshow ..." part from the file and the text "blah" will appear in your ghostscript viewer. Well, this is my first test with FuncMP and that's why I'm asking this silly question now: Is the "fshow" function really necessary or can I remove it from every generated .ps file without problems? :) Or you know another solution? Does your generated .ps files also contain this code? If no, what version of FuncMP do you use? -- View this message in context: http://www.nabble.com/Functional-MetaPost-in-5-Steps-tp20144360p21070707.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From duncan.coutts at worc.ox.ac.uk Thu Dec 18 07:57:30 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 18 07:50:07 2008 Subject: [Haskell-cafe] Re: [Haskell] possible bug in pretty-1.0.1.0 In-Reply-To: <20081215161756.GA29082@berkeley.edu> References: <20081215161756.GA29082@berkeley.edu> Message-ID: <1229605050.10115.690.camel@localhost> On Mon, 2008-12-15 at 08:17 -0800, John MacFarlane wrote: > I noticed a difference in how "hang" works between pretty-1.0.0.0 and > pretty-1.0.1.0. I think it's a bug. If this isn't the right place to > report it, please let me know where I should. (Maintainer is listed > as libraries@haskell.org, but that is a closed mailing list. Perhaps > Cabal should include a report-bugs-at field?) I'd just like to advertise the fact that as of Cabal-1.6 you can put a bug-reports field in your .cabal file and it will be displayed by hackage. We would like to encourage all package authors to use this. It can be a mailto: url to a maintainer or mailing list or it can be a http: url to a bug tracker website. (Cabal-1.6 also supports specifying darcs/git/whatever repos) Duncan From holgersiegel74 at yahoo.de Thu Dec 18 08:03:40 2008 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Thu Dec 18 07:56:21 2008 Subject: [Haskell-cafe] Detecting system endianness In-Reply-To: <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> Message-ID: <200812181403.40459.holgersiegel74@yahoo.de> On Thursday 18 December 2008 13:40:47 Ryan Ingram wrote: > Actually, this is probably safer: > > import Foreign.Marshal.Alloc > import Foreign.Ptr > import Foreign.Storable > import Data.Word > import System.IO.Unsafe > > endianCheck = unsafePerformIO $ alloca $ \p -> poke p (0x01020304 :: > Word32) >> peek (castPtr p :: Ptr Word8) > > littleEndian = endianCheck == 4 > bigEndian = endianCheck == 1 > > -- ryan > > On Thu, Dec 18, 2008 at 4:33 AM, Ryan Ingram wrote: > > I think something like this might work: > > > > Prelude GHC.Exts GHC.Word> let W64# x = 0x100000002 in W32# > > (unsafeCoerce# x) 2 > > > > You should get 1 for big-endian and 2 for little-endian. > > > > (Disclaimer: not particularily well-tested.) Using modules Data.Binary, Data.Binary.Put and Data.Word, you can define littleEndian = (decode $ runPut $ putWord16host 42 :: Word8) == 42 Under the hood, it also uses peek and poke, but it looks a bit more functional. From ndmitchell at gmail.com Thu Dec 18 08:27:57 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Dec 18 08:20:31 2008 Subject: [Haskell-cafe] Re: [Haskell] possible bug in pretty-1.0.1.0 In-Reply-To: <1229605050.10115.690.camel@localhost> References: <20081215161756.GA29082@berkeley.edu> <1229605050.10115.690.camel@localhost> Message-ID: <404396ef0812180527v7f46869ax425c003215225a3d@mail.gmail.com> Hi Duncan, > I'd just like to advertise the fact that as of Cabal-1.6 you can put a > bug-reports field in your .cabal file and it will be displayed by > hackage. Fantastic. Is it backwards compatible? i.e. if I add such a field, will Cabal-1.2 give warnings/errors? Thanks Neil From nhn at Cs.Nott.AC.UK Thu Dec 18 08:26:33 2008 From: nhn at Cs.Nott.AC.UK (Henrik Nilsson) Date: Thu Dec 18 08:51:30 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> Message-ID: <494A4F89.5090802@cs.nott.ac.uk> Hi Tom, > I'll have an attempt at addressing the questions, although I freely > admit that I'm not as "into" Reactive as Conal is yet, so he may come > and correct me in a minute. > [...] > Reactive has explicitly parameterized inputs. In your robot example I > would expect something along the lines of > > data RobotInputs = > RI {lightSensor :: Behavior Colour; > bumbSwitch :: Event ()} -- A couple of example robot sensors > > robotBehavior :: RobotInputs -> Behavior Robot > robotBehavior sensors = a behovior that combines the light sensor and > the bumb switch to stay in the light, but not keep driving into > things. This looks exactly like Classical FRP. And if it is like Classical FRP behind the scenes, it nicely exemplifies the problem. In Classical FRP, Behavior is actually what I would call a signal function. When started (switched into), they map the system input signal from that point in time to a signal of some particular type. So, the record RobotInputs is just a record of lifted projection functions that selects some particular parts of the overall system input. Behind the scenes, all Behaviors are connected to the one and only system input. > data UIInputs = UI {mousePoint :: Behavior Point; mouseClick :: Event > (); ...} > > world :: UIInputs -> Behavior World > world = interpret mouse and produce a world with barriers, robots and > lights in it Fine, of course, assuming that all behaviours share the same kind of system input, in this case UI input. But what if I want my reactive library to interface to different kinds of systems? The robot code should clearly work regardless of whether we are running it on a real hardware platform, or in a simulated setting where the system input comes form the GUI. In Classical FRP, this was not easily possible, because all combinators at some level need to refer to some particular system input type which is hardwired into the definitions. Had Haskell had ML-style parameterized modules, that would likely have offered a solution: the libraries could have been parameterized on the system input, and then one could obtain say robot code for running on real hardware or in a simulated setting by simply applying the robot module to the right kind of system input. An alternative is to parameterize the behaviour type explicitly on the system input type: Behavior sysinput a This design eventually evolved into Arrowized FRP and Yampa. So, from your examples, it is not clear to what extent Reactive as addressed this point. Just writing functions that maps behaviours to behaviours does not say very much. On a more philosophical note, I always found it a bit odd that if I wanted to write a function that mapped a signal of, say, type "a", which we can think of as type Signal a = Time -> a to another signal, of type "b" say, in Classical FRP, I'd have to write a function of type Behavior a -> Behavior b which really is a function of type (Signal SystemInput -> Signal a) -> (Signal SystemInput -> Signal b) I find this unsatisfying, as my mapping from a signal of type a to a signal of type b is completely independent from the system input (or the function wouldn't have a polymorphic type). > > * A clear separation between signals, signal functions, and ordinary > > functions and values, yet the ability to easily integrate all > > kinds of computations. > > I agree and disagree here (that'll be the matter of taste creeping > in). I agree that in Reactive you often spend a lot of keystrokes > lifting pure values into either an Event or a Behavior. Having said > that I'd argue that Yampa requires us to do this too -- it merely > enforces the style in which we do it (we must do it with arrows). Yes, there is lifting in Yampa, but the arrow syntax mostly does it for the programmer, which in practice (in my experience) translates to a lot less effort, and, in my opinion, leads to clearer code as it is easy to maintain a distinction between signals and static values. After all, why should I want to live a constant to a signal, if all I'm going to do with it is to apply one and the same function to it over and over? (I'm not worried about efficiency here, that can be fixed: it's a philosophical point.) Also, form practical experience when programming with Classical FRP, we often lifted entire libraries we wanted to use to avoid having to write explicit lifts all the time. Tedious, but OK, doable. However, quite often we then discovered that actually, we needed the unlifted version of the library too, leading to name clashes and thus extra noise to do the need to disambiguate, be it by qualified input or naming the lifted versions differently. Not a show stopper by any means, but a tedious extra level of concerns. The arrow framework offer clear guidance in this case which translates to convenient coding practice: just use whatever library you need and let the arrow syntax take care of liftings where necessary. > My personal opinion on this one is that I prefer the applicative > interface to the arrow based one, because it feels more like just > writing a functional program. It is true that the arrow syntax sometimes is a bit too "linear". For example, if (without using the basic arrow combinators), I want to apply first one function sf1 and then another sf2 to some signal x, one might write y <- sf1 -< x z <- sf1 -< y whereas z = sf1 (sf2 x) would arguably be clearer in a case like this. On balance, though, I find that the advantages of the arrow framework outweighs such inconveniences. (Of course, one can also write z <- sf2 <<< sf1 -< x And I think the arrow syntax likely could be tweaked to allow something more similar to the second version, but that's of course beside the point.) > I reserve judgement at the moment because I haven't explicitly written > a reactive program involving a collection of behaviors, having said > that, I see no reason why removing a value from the list in a Behavior > [a], it should not get garbage collected. But just the possibility of have list output is not sufficient. What is needed is a way to run a collection of independent behaviours in parallel. Classical FRP provided essentially the following functionality for this purpose: [Behavior a] -> Behavior [a] This is fine, until we get to a point where we want to remove one of those behaviors without disturbing the others. In Classical FRP, the only thing that could be done was to apply a filter to the output list to *hide* the output(s) from some of the behaviours from the outside world. But this only makes it *look* as if they're gone. In fact, they're still there, consuming computational resources, and can be resurrected at any point. Yampa provides a way of maintaining dynamic collections of signal functions, allowing new signal functions to be started and others to be removed without affecting the other signal functions in the collection. It is still unclear to me if Reactive offers anything similar. In principle, just looking from the outside, I cannot see why reactive couldn't do something similar to Yampa or possibly adopt some other design to the same effect. But my understanding is that Reactive has a fairly elaborate run-time machinery behind the scenes, and I don't know if that would get in the way or not. > > * There was also an issue with Classical FRP having to do with the > > need to observe the output from one part of the system in > > another part of the system. > > My understanding is that Conal went to great lengths to make sure that > Behaviors get correctly cached, so that incremental values are only > evaluated once, but I'm affraid I can't answer this more sensibly. This is a semantical issue, not one about efficiency. The question is this. Suppose we define let n :: Behavior Int n = in n `until` -=> n I'm not sure I got the syntax right. But the idea is that we output the number of left mouse button clicks, and then at some point, we switch to a behavior that again output the number of left mouse button clicks, notionally the "same" one "n". The question is, after the switch, do we observe a count that continues from where the old one left off, i.e. is there a single *shared* instance of "n" that is merely being *observed* from within the two "branches" of the switch, or is the counting behavior "n" restarted (from 0) after the switch? In Classical FRP, the answer is the latter (because "n" really is a signal function mapping system input to an signal carrying integer counts). Sometimes that's what one wants, other times not. Which is what motivated the "running in" design to effectively allow a single instance of a behavior to be created, whose output then could be observed within the scope of the definition thus avoiding restarting the behavior after each switch. But this design became very complicated, and also somewhat confusing as there was no type distinction between "running behaviors" (effectively signals) and behaviors (signal functions). Yampa, by effectively providing both signals and signal functions, provides a much simpler answer, albeit at the price of a bit of extra "plumbing" sometimes. Again, I don't know where Reactive stands on this. But it is a real concern in terms of being able to express what one need to express in real-life reactive programming, i.e. more than just a matter of taste in this case. > Your email triggered to think about a couple of the other significant > differences between Yampa and Reactive > * Reactive deals with continuous functions of time, not sampled ones. > This allows for asynchronous sampling, for example the ability to > sample a Behavior at 1/60th of a second rate for screen refreshes, > while sampling the same behavior also at 1/10th second for logging, > and 1/1000th for euler integration of un-integratable Behaviors. I'm not quite sure what you're getting at here. On the one hand, Yampa also notionally has continuous time. On the other hand, ANY implementation will have to do sampling at some point. But I suppose what you're saying is that Reactive allows different part of a system to be sampled at different rates in a transparent manner? Which is nice. But the tradeoffs are not clear to me. > * Reactive is push based. The result of this is that we will not > waste CPU cycles for example refreshing the screen when nothing has > changed on the output. The optimizations of Yampa also achieves a fair amount of "pushing". But granted, Yampa is fundamentally pull-based. That said, for truly hybrid systems, that do a lot of continuous computation, it is not at all clear that push is a clear winner. Only extensive benchmarking can really provide genuine insight into the actual pros and cons here of different FRP implementations for various applications, I'd say. Also, when there is a need to combine output from different parts of a system, and this is done by combining the various outputs into a tuple or record, then one have to push combined output whenever any one of the constituent parts changes, which means one lose track of the changes down the line, possibly resulting in redundant computations anyway. Best, /Henrik -- Henrik Nilsson School of Computer Science The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From jgoerzen at complete.org Thu Dec 18 09:13:57 2008 From: jgoerzen at complete.org (John Goerzen) Date: Thu Dec 18 09:06:38 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <494811DD.5070908@btinternet.com> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> Message-ID: <494A5AA5.9010806@complete.org> Andrew Coppin wrote: > Don Stewart wrote: >> I think of Haskell more as a revolutionary movement > > LOL! Longest revolution EVER, eh? I mean, how long ago was its dogma > first codified? ;-) Lisp has been around for how long now? Measured in decades. We don't even have our version of a Symbolics machine yet! > Basically, Haskell will never be popular, but its coolest ideas will be > stolen by everybody else and passed off as their own. :-( Well, in a sense, if that happens, we would have won, right? We'd have created a situation where "paradigm shift" would mean more than just a buzzword on some CEO's presentation slide ;-) In another sense, isn't this what Haskell was explicitly created to do? (Combine ideas from a bunch of similar languages into one standard one) Some ideas in Haskell are easy to integrate into other languages: see list comprehensions in Python. I don't see Perl picking up pervasive laziness anytime soon, nor Python compile-time type inference. -- John From dvde at gmx.net Thu Dec 18 09:45:54 2008 From: dvde at gmx.net (Daniel van den Eijkel) Date: Thu Dec 18 09:38:34 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <1229462496.17249.8.camel@jcchost> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <1229462496.17249.8.camel@jcchost> Message-ID: <494A6222.9060806@gmx.net> as some german right-hegelian thinkers of the beginning of the 20th century noticed, the hegelian system is missing what we call 'action'. the whole system can be described as a timeless and closed set of invariant relations between parts of the world, which can also be seen as gods thinking. this critique is similar to the marxist turn of the hegelian philosophy. now, thinking of an timeless set of invariant relations, that should be extended by some concept of action, reminds me of haskell's monads. so I would say, haskell is not a revolutionary movement itself, its just a (or: THE) vehicle of the revolutionary progress that started 200 years ago (some might say, 2000 years ago). it's the place where the 'spirit of the world' comes to itself in these days... just kidding. daniel Jonathan Cast schrieb: > On Tue, 2008-12-16 at 20:38 +0000, Andrew Coppin wrote: > >> Don Stewart wrote: >> >>> I think of Haskell more as a revolutionary movement >>> >> LOL! Longest revolution EVER, eh? >> > > No. > > Das Kapital publication 1867. > Russian Revolution 1917. > > FTW. > > jcc > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-caf From duncan.coutts at worc.ox.ac.uk Thu Dec 18 10:32:24 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 18 10:25:00 2008 Subject: [Haskell-cafe] Re: [Haskell] possible bug in pretty-1.0.1.0 In-Reply-To: <404396ef0812180527v7f46869ax425c003215225a3d@mail.gmail.com> References: <20081215161756.GA29082@berkeley.edu> <1229605050.10115.690.camel@localhost> <404396ef0812180527v7f46869ax425c003215225a3d@mail.gmail.com> Message-ID: <1229614344.10115.691.camel@localhost> On Thu, 2008-12-18 at 13:27 +0000, Neil Mitchell wrote: > Hi Duncan, > > > I'd just like to advertise the fact that as of Cabal-1.6 you can put a > > bug-reports field in your .cabal file and it will be displayed by > > hackage. > > Fantastic. Is it backwards compatible? i.e. if I add such a field, > will Cabal-1.2 give warnings/errors? It should give warnings but not errors. Unfortunately for the source repo stuff that uses a new section which the old parser did not handle quite so gracefully. Duncan From agocorona at gmail.com Thu Dec 18 10:37:53 2008 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Dec 18 10:30:27 2008 Subject: Fwd: [Haskell-cafe] Haskell as a religion In-Reply-To: References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> Message-ID: But many features need other features. For example, the option to use referential transparency will be common in future languages for multicore programming purposes. This creates the problem of separating side-effect-free code from side-effect code. For this purpose, a strong type system at compile time is needed, which indeed need automatic type inference or, else, the user will be too busy with the details. The type inference open the door for experimenting with complex data types. class types is a logical step after that. Monads are the best option for many problems once the programmer have all te above. higuer order functions are being taken seriously in other languages. this goes to the need of currying and lists. optional lazyness and tail recursion is the most elegant option for expressing lists managing code. Will all the above, explicit loops will be avoided by the programmer, this will end up in mode declarative programming style. I think that once the average programmer start to use one or two of these features, he will feel a bit frustrated if its language don?t have all the others, specially if he know haskell. Probably, he will use haskell for fun. This is the best way for the takeover of the industry, because this has been so historically. 2008/12/18 John Goerzen Andrew Coppin wrote: > > Don Stewart wrote: > >> I think of Haskell more as a revolutionary movement > > > > LOL! Longest revolution EVER, eh? I mean, how long ago was its dogma > > first codified? ;-) > > Lisp has been around for how long now? Measured in decades. We don't > even have our version of a Symbolics machine yet! > > > Basically, Haskell will never be popular, but its coolest ideas will be > > stolen by everybody else and passed off as their own. :-( > > Well, in a sense, if that happens, we would have won, right? We'd have > created a situation where "paradigm shift" would mean more than just a > buzzword on some CEO's presentation slide ;-) > > In another sense, isn't this what Haskell was explicitly created to do? > (Combine ideas from a bunch of similar languages into one standard one) > > Some ideas in Haskell are easy to integrate into other languages: see > list comprehensions in Python. I don't see Perl picking up pervasive > laziness anytime soon, nor Python compile-time type inference. > > -- John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081218/78c7a204/attachment.htm From allbery at ece.cmu.edu Thu Dec 18 11:05:05 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Dec 18 10:57:52 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <1153550968.20081218134711@gmail.com> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> <63D2ECC4-C48D-46F7-91AE-9CE05240381B@yandex.ru> <1153550968.20081218134711@gmail.com> Message-ID: <862EC73A-A4BD-4EFB-B11E-18E5F60725A4@ece.cmu.edu> On 2008 Dec 18, at 5:47, Bulat Ziganshin wrote: > ruby doesn't support coroutines, but only iterators (where control > moved from caller to callee). usually control is on the caller side, > and coroutines gives control to both (or many) sides Right, and you don't normally do iterators in Haskell; you do map/fmap. -- 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 allbery at ece.cmu.edu Thu Dec 18 11:27:14 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Dec 18 11:19:50 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <494A5AA5.9010806@complete.org> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> Message-ID: On 2008 Dec 18, at 9:13, John Goerzen wrote: > Some ideas in Haskell are easy to integrate into other languages: see > list comprehensions in Python. I don't see Perl picking up pervasive > laziness anytime soon, nor Python compile-time type inference. I think perl6 is specced with pervasive laziness, although I'm not sure it's actually implemented anywhere. -- 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 brad.larsen at gmail.com Thu Dec 18 11:34:21 2008 From: brad.larsen at gmail.com (Brad Larsen) Date: Thu Dec 18 11:26:51 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> Message-ID: On Thu, 18 Dec 2008 11:27:14 -0500, Brandon S. Allbery KF8NH wrote: > On 2008 Dec 18, at 9:13, John Goerzen wrote: >> Some ideas in Haskell are easy to integrate into other languages: see >> list comprehensions in Python. I don't see Perl picking up pervasive >> laziness anytime soon, nor Python compile-time type inference. > > I think perl6 is specced with pervasive laziness, although I'm not > sure it's actually implemented anywhere. I'm not sure about pervasive, but I read somewhere that Perl 6's lists are head-strict, tail-lazy by default... Regards, Brad Larsen From p.f.moore at gmail.com Thu Dec 18 11:47:11 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Thu Dec 18 11:39:45 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> Message-ID: <79990c6b0812180847t85e7b04h7c3ad2df9bbdfe88@mail.gmail.com> 2008/12/18 Brandon S. Allbery KF8NH : > On 2008 Dec 18, at 9:13, John Goerzen wrote: >> >> Some ideas in Haskell are easy to integrate into other languages: see >> list comprehensions in Python. I don't see Perl picking up pervasive >> laziness anytime soon, nor Python compile-time type inference. > > I think perl6 is specced with pervasive laziness, although I'm not sure it's > actually implemented anywhere. I assumed it was implemented lazily, so that when you use it somewhere, the Perl 6 developers implement that part of the feature :-) Paul. From allbery at ece.cmu.edu Thu Dec 18 11:48:30 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Dec 18 11:41:06 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <79990c6b0812180847t85e7b04h7c3ad2df9bbdfe88@mail.gmail.com> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> <79990c6b0812180847t85e7b04h7c3ad2df9bbdfe88@mail.gmail.com> Message-ID: <2BE0E45B-A873-45E9-8366-C89E839ABB9C@ece.cmu.edu> On 2008 Dec 18, at 11:47, Paul Moore wrote: > 2008/12/18 Brandon S. Allbery KF8NH : >> On 2008 Dec 18, at 9:13, John Goerzen wrote: >>> >>> Some ideas in Haskell are easy to integrate into other languages: >>> see >>> list comprehensions in Python. I don't see Perl picking up >>> pervasive >>> laziness anytime soon, nor Python compile-time type inference. >> >> I think perl6 is specced with pervasive laziness, although I'm not >> sure it's >> actually implemented anywhere. > > I assumed it was implemented lazily, so that when you use it > somewhere, the Perl 6 developers implement that part of the feature > :-) Lot of truth to that at the moment :) -- 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 tom.davie at gmail.com Thu Dec 18 11:53:24 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Dec 18 11:46:03 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <494A4F89.5090802@cs.nott.ac.uk> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> Message-ID: <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> Hi Henrik, On 18 Dec 2008, at 14:26, Henrik Nilsson wrote: > Hi Tom, > > > I'll have an attempt at addressing the questions, although I freely > > admit that I'm not as "into" Reactive as Conal is yet, so he may > come > and correct me in a minute. > > [...] > > Reactive has explicitly parameterized inputs. In your robot > example I > would expect something along the lines of > > > > data RobotInputs = > > RI {lightSensor :: Behavior Colour; > > bumbSwitch :: Event ()} -- A couple of example robot sensors > > > > robotBehavior :: RobotInputs -> Behavior Robot > > robotBehavior sensors = a behovior that combines the light sensor > and > the bumb switch to stay in the light, but not keep driving into > > things. > > This looks exactly like Classical FRP. > And if it is like Classical FRP behind the scenes, it nicely > exemplifies the problem. > > In Classical FRP, Behavior is actually what I would call a signal > function. When started (switched into), they map the system input > signal from that point in time to a signal of some particular type. > > So, the record RobotInputs is just a record of lifted projection > functions that selects some particular parts of the overall system > input. Behind the scenes, all Behaviors are connected to the one > and only system input. I don't think this is really true. Behaviors and Events do not reveal in their type definitions any relation to any system that they may or may not exist in. A Behavior can exist wether or not it is being run by a particular legacy adapter (a piece of code to adapt it to work as expected on a legacy, imperative computer). I can define an Event e = (+1) <$ atTimes [0,10..] and use it as a Haskell construct without needing any system at all to run it within. Similarly I can define a Behavior b = accumB 0 e that depends on this event, completely independant of any system, or definition of what basic events and behaviors I get to interact with it. > > data UIInputs = UI {mousePoint :: Behavior Point; mouseClick :: > Event > > (); ...} > > > > world :: UIInputs -> Behavior World > > world = interpret mouse and produce a world with barriers, robots > and > lights in it > > Fine, of course, assuming that all behaviours share the same kind > of system input, in this case UI input. > > But what if I want my reactive library to interface to different kinds > of systems? The robot code should clearly work regardless of whether > we are running it on a real hardware platform, or in a simulated > setting where the system input comes form the GUI. In Classical FRP, > this was not easily possible, because all combinators at some level > need to refer to some particular system input type which is hardwired > into the definitions. There are no hardwired definitions of what inputs I'm allowed to use or not use. If I would like my reactive program to run on a "legacy" robot which uses imperative IO, then I may write a legacy adapter around it to take those IO actions and translate them into Events and Behaviors that I can use. One such legacy adapter exists, called reactive-glut, which ties glut's IO actions into reactive events one can use. I could easily imagine several others, for example one that interacts with robot hardware and presents the record above to the behaviors it's adapting, or another still which works much like the "interact" function, but instead of taking a String -> String, takes an Event Char -> Event Char. > Had Haskell had ML-style parameterized modules, > that would likely have offered a solution: the libraries could > have been parameterized on the system input, and then one could obtain > say robot code for running on real hardware or in a simulated > setting by simply applying the robot module to the right kind of > system input. > > An alternative is to parameterize the behaviour type explicitly on > the system input type: > > Behavior sysinput a > > This design eventually evolved into Arrowized FRP and Yampa. > > So, from your examples, it is not clear to what extent Reactive > as addressed this point. Just writing functions that maps behaviours > to behaviours does not say very much. > > On a more philosophical note, I always found it a bit odd that if > I wanted to write a function that mapped a signal of, say, type "a", > which we can think of as > > type Signal a = Time -> a > > to another signal, of type "b" say, in Classical FRP, I'd have to > write > a function of type > > Behavior a -> Behavior b > > which really is a function of type > > (Signal SystemInput -> Signal a) -> (Signal SystemInput -> Signal > b) > I find this unsatisfying, as my mapping from a signal of type a to > a signal of type b is completely independent from the system > input (or the function wouldn't have a polymorphic type). Yes, certainly that would be unsatisfactory. But I don't agree about the type of the function -- this really is a (Time -> a) -> (Time -> a). It may be though that the argument (Time -> a) is a system input from our legacy adapter, or an internal part of our program. > > > * A clear separation between signals, signal functions, and > ordinary > > > functions and values, yet the ability to easily integrate all > > > kinds of computations. > > > > I agree and disagree here (that'll be the matter of taste creeping > > in). I agree that in Reactive you often spend a lot of keystrokes > > lifting pure values into either an Event or a Behavior. Having said > > that I'd argue that Yampa requires us to do this too -- it merely > > enforces the style in which we do it (we must do it with arrows). > > Yes, there is lifting in Yampa, but the arrow syntax mostly does it > for > the programmer, which in practice (in my experience) translates to a > lot > less effort, and, in my opinion, leads to clearer code as it is easy > to > maintain a distinction between signals and static values. After all, > why > should I want to live a constant to a signal, if all I'm going to do > with it is to apply one and the same function to it over and over? > > (I'm not worried about efficiency here, that can be fixed: it's > a philosophical point.) I'm not sure I understand you clearly. If I wish to apply a constant function to a signal, can I not just use fmap? > Also, form practical experience when programming with Classical FRP, > we often lifted entire libraries we wanted to use to avoid having > to write explicit lifts all the time. Tedious, but OK, doable. > > However, quite often we then discovered that actually, we needed the > unlifted version of the library too, leading to name clashes and > thus extra noise to do the need to disambiguate, be it by qualified > input or naming the lifted versions differently. > > > Not a show stopper by any means, but a tedious extra level of > concerns. > > The arrow framework offer clear guidance in this case which translates > to convenient coding practice: just use whatever library > you need and let the arrow syntax take care of liftings where > necessary. > > > My personal opinion on this one is that I prefer the applicative > > interface to the arrow based one, because it feels more like just > > writing a functional program. > > It is true that the arrow syntax sometimes is a bit too "linear". For > example, if (without using the basic arrow combinators), I want to > apply > first one function sf1 and then another sf2 to some signal x, one > might write > > y <- sf1 -< x > z <- sf1 -< y > > whereas > > z = sf1 (sf2 x) > > would arguably be clearer in a case like this. > > On balance, though, I find that the advantages of the arrow framework > outweighs such inconveniences. > > (Of course, one can also write > > z <- sf2 <<< sf1 -< x Or one could write z = sf2 <$> (sf1 <$> x) in Reactive -- unfortunately, we pay the penalty of having to use a bulkier syntax for application than just ' ', but it still works rather nicely. I agree that the arrow notation is nice in some circumstances, but my (admitedly limited) experience with Yampa left me often finding that I wanted to express something much more simply, and less sequentially without the arrows. > And I think the arrow syntax likely could be tweaked to allow > something more similar to the second version, but that's of course > beside the point.) > > > I reserve judgement at the moment because I haven't explicitly > written > > a reactive program involving a collection of behaviors, having said > > that, I see no reason why removing a value from the list in a > Behavior > [a], it should not get garbage collected. > > But just the possibility of have list output is not sufficient. > > What is needed is a way to run a collection of independent > behaviours in > parallel. Classical FRP provided essentially the following > functionality > for this purpose: > > [Behavior a] -> Behavior [a] Certainly, I can imagine something along the lines of listB = foldr (liftA2 (:)) (pure []) -- there's that lifting creaping in. > This is fine, until we get to a point where we want to remove > one of those behaviors without disturbing the others. > > In Classical FRP, the only thing that could be done was to > apply a filter to the output list to *hide* the output(s) from some > of the behaviours from the outside world. But this only makes it > *look* as if they're gone. In fact, they're still there, consuming > computational resources, and can be resurrected at any point. > > Yampa provides a way of maintaining dynamic collections of signal > functions, allowing new signal functions to be started and others > to be removed without affecting the other signal functions in the > collection. > > It is still unclear to me if Reactive offers anything similar. > In principle, just looking from the outside, I cannot see why reactive > couldn't do something similar to Yampa or possibly adopt some other > design to the same effect. But my understanding is that Reactive has > a fairly elaborate run-time machinery behind the scenes, and I don't > know if that would get in the way or not. You would certainly need to ask Conal on this point, but I have no reason to suspect that b' = [1,2,3,4,5] `stepper` listE [(1,[])] would not deallocate the first list once it had taken its step. > > > * There was also an issue with Classical FRP having to do with the > > > need to observe the output from one part of the system in > > > another part of the system. > > > > My understanding is that Conal went to great lengths to make sure > that > Behaviors get correctly cached, so that incremental values > are only > > evaluated once, but I'm affraid I can't answer this more sensibly. > > This is a semantical issue, not one about efficiency. > > The question is this. Suppose we define > > let > n :: Behavior Int > n = > in > n `until` -=> n > > I'm not sure I got the syntax right. But the idea is that we > output the number of left mouse button clicks, and then at some > point, we switch to a behavior that again output the number of left > mouse button clicks, notionally the "same" one "n". > > The question is, after the switch, do we observe a count that > continues from where the old one left off, i.e. is there a > single *shared* instance of "n" that is merely being *observed* > from within the two "branches" of the switch, or is the counting > behavior "n" restarted (from 0) after the switch? Yes, we really do get a shared n -- without doing that we certainly would see a large space/time leak. > In Classical FRP, the answer is the latter (because "n" really > is a signal function mapping system input to an signal carrying > integer counts). Yep, in Reactive, a signal function is a newtype BehaviorG tr tf a = Beh { unBeh :: (R.ReactiveG tr :. Fun tf) a } i.e. it's a Reactive value containing functions of time. Each mouse click event would create a new step in the Reactive value, allowing (a) the old step to be garbage collected, (b) the value for the current number of mouse clicks to be cached. What may be a problem, is if we do not look at our mouse-click counting behavior for a long time, we may spend a lot of time when we do look at it, computing all of the (+1)s we have built up (but only once). > Sometimes that's what one wants, other times not. Which is what > motivated the "running in" design to effectively allow a single > instance of a behavior to be created, whose output then could > be observed within the scope of the definition thus avoiding > restarting the behavior after each switch. But this design > became very complicated, and also somewhat confusing as there > was no type distinction between "running behaviors" (effectively > signals) and behaviors (signal functions). Yep, such Behaviors are seperated in Reactive only by the method you create them with. I may use the `stepper` function to create a behavior that increases in steps based on an event occurring, or I may use fmap over time to create a continuously varying Behavior. > > Your email triggered to think about a couple of the other > significant > differences between Yampa and Reactive > > * Reactive deals with continuous functions of time, not sampled > ones. > This allows for asynchronous sampling, for example the > ability to > > sample a Behavior at 1/60th of a second rate for screen refreshes, > > while sampling the same behavior also at 1/10th second for logging, > > and 1/1000th for euler integration of un-integratable Behaviors. > > I'm not quite sure what you're getting at here. > > On the one hand, Yampa also notionally has continuous time. > On the other hand, ANY implementation will have to do sampling > at some point. > > But I suppose what you're saying is that Reactive allows different > part of a system to be sampled at different rates in a transparent > manner? > > Which is nice. > > But the tradeoffs are not clear to me. Yes, indeed reactive allows different sample rates as you say. The key though is that reactive itself does not ever do any sampling. The user may create Events, and snapshot Behaviors at the times that the Events occur, but reactive will never explicitly say "I am going to sample now". What may happen, is that the legacy adapter may have a built in Event at which it samples for (for example) screen refreshes. > > * Reactive is push based. The result of this is that we will not > > waste CPU cycles for example refreshing the screen when nothing > has > > changed on the output. > > The optimizations of Yampa also achieves a fair amount of "pushing". > But granted, Yampa is fundamentally pull-based. > > That said, for truly hybrid systems, that do a lot of continuous > computation, it is not at all clear that push is a clear winner. Yes, I agree. This is one of the things I'll be interested to discover, working with Reactive, is exactly when we have problems with the push based semantics. > Only extensive benchmarking can really provide genuine insight > into the actual pros and cons here of different FRP implementations > for various applications, I'd say. > > Also, when there is a need to combine output from different > parts of a system, and this is done by combining the various > outputs into a tuple or record, then one have to push combined > output whenever any one of the constituent parts changes, which > means one lose track of the changes down the line, possibly > resulting in redundant computations anyway. I'm not certain that this is the case. I *hope* that the caching in the Behaviors is enough that this computation is avoided, but I'm not 100% certain. I hope I got more on top of the problems you were pointing out this time. Thanks Tom Davie From vanenkj at gmail.com Thu Dec 18 11:53:39 2008 From: vanenkj at gmail.com (John Van Enk) Date: Thu Dec 18 11:47:50 2008 Subject: [Haskell-cafe] Haskell, successing crossplatform API standart In-Reply-To: <21067779.post@talk.nabble.com> References: <20742743.post@talk.nabble.com> <5CDE013B-1F09-48A9-8946-93959E911E52@gmail.com> <21067779.post@talk.nabble.com> Message-ID: > Oh, but JSON doesn't seem to support tree-structured data... { "value" : 5, "left" : { "value" : 3, "left" : null, "right" : null }, "right" : { "value" : 8, "left" : null, "right" : null } } JSON *is* tree structured data. /jve On Thu, Dec 18, 2008 at 1:41 AM, Belka wrote: > > Thanks for the info! > > > These days, however, web services seem to be moving towards a RESTful > model with a JSON layer and there are plenty of JSON libraries on > hackage, which you could just throw over the fastCGI bindings. > > Oh, but JSON doesn't seem to support tree-structured data... This might > turn > into hell, when highly demanded in big infrastructures with complex > communications. That's why I guess my choise will be XML. Don't know any > good alternative with total support on every platform. > -- > View this message in context: > http://www.nabble.com/Haskell%2C-successing-crossplatform-API-standart-tp20742743p21067779.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081218/7ac43114/attachment.htm From duncan.coutts at worc.ox.ac.uk Thu Dec 18 12:12:05 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 18 12:04:48 2008 Subject: [Haskell-cafe] gtk2hs question - derive SettingsWindow from Window In-Reply-To: <1ff5dedc0812121203v525ddf6djde04e33ac493f2e4@mail.gmail.com> References: <1ff5dedc0812121203v525ddf6djde04e33ac493f2e4@mail.gmail.com> Message-ID: <1229620325.10115.706.camel@localhost> On Fri, 2008-12-12 at 21:03 +0100, Cetin Sert wrote: > Hi all, > > For a network manager of sorts I'm working on, I want to derive a > SettingsWindowClass from the WindowClass present in Gtk2Hs: > > I want (the) instance(s) of the SettingsWindowClass to have a field to > store connection settings: > > 1) Is it safe to do it like this? You've missed out the unsafe bit where you make SettingsWindow an instance of class WindowClass. That bit will not work because the upcast function is not a proper Haskell function just is just a pointer cast. Currently the assumption is that each gtk2hs type is backed by a C type held in a ForeignPtr. We should generalise that to allow subclasses defined in Haskell. > class WindowClass self ? SettingsWindowClass self where > settingsWindowGetSettings :: self ? IO [ConnectionSetting] > settingsWindowSetSettings :: self ? [ConnectionSetting] ? IO () > > newtype SettingsWindow = SettingsWindow (Window,[ConnectionSetting]) So you can use this newtype, you just can't make it an instance of WindowClass. > mkSettingsWindow = SettingsWindow > unSettingsWindow (SettingsWindow o) = o > > settingsWindowNew :: IO SettingsWindow > settingsWindowNew = do > win ? windowNew > return $ mkSettingsWindow (win,[]) > > 2) Is this a common practice in gtk2hs usage? Making records of widgets is pretty common. > 3) And will GC properly free the memory allocated for the Window > object? How is this ensured, do ForeignPtr's always call delete on the > underlying C ptr when they get garbage collected? Right, exactly. Duncan From newsham at lava.net Thu Dec 18 12:39:34 2008 From: newsham at lava.net (Tim Newsham) Date: Thu Dec 18 12:32:10 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> Message-ID: > Andrew was recently asking about co-routines. A couple of years ago, > I was in much the same position as him; although I am pretty sure I > had heard the term before, it seemed like a mysterious idea with no > practical use. Besides the point that people have already made that lazy evaluation gives you similar control as coroutines, I wanted to point out how simple it is to implement coroutines. Here's a simple implementation that ddarius made on IRC a few months back off-the-cuff. I kept it around on codepad because its cool: http://codepad.org/GwtS6wMj > -- ryan Tim Newsham http://www.thenewsh.com/~newsham/ From bulat.ziganshin at gmail.com Thu Dec 18 12:51:19 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Dec 18 12:47:23 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <862EC73A-A4BD-4EFB-B11E-18E5F60725A4@ece.cmu.edu> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> <63D2ECC4-C48D-46F7-91AE-9CE05240381B@yandex.ru> <1153550968.20081218134711@gmail.com> <862EC73A-A4BD-4EFB-B11E-18E5F60725A4@ece.cmu.edu> Message-ID: <1947509678.20081218205119@gmail.com> Hello Brandon, Thursday, December 18, 2008, 7:05:05 PM, you wrote: >> ruby doesn't support coroutines, but only iterators (where control >> moved from caller to callee). usually control is on the caller side, >> and coroutines gives control to both (or many) sides > Right, and you don't normally do iterators in Haskell; you do map/fmap. iterators are not cycles :) they allow to return value without returning control -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From nhn at Cs.Nott.AC.UK Thu Dec 18 13:06:46 2008 From: nhn at Cs.Nott.AC.UK (Henrik Nilsson) Date: Thu Dec 18 13:01:29 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> Message-ID: <494A9136.1040903@cs.nott.ac.uk> Hi Tom, > I don't think this is really true. Behaviors and Events do not reveal > in their type definitions any relation to any system that they may or > may not exist in. OK. So how does e.g. mousePoint :: Behavior Point get at the mouse input? unsafePerformIO? I.e. it is conceptually a global signal? > I'm not sure I understand you clearly. If I wish to apply a constant > function to a signal, can I not just use fmap? The question is why I would want to (conceptually). I'm just saying I find it good and useful to be able to easily mix static values and computations and signals and computations on signals. > You would certainly need to ask Conal on this point, but I have no > reason to suspect that b' = [1,2,3,4,5] `stepper` listE [(1,[])] would > not deallocate the first list once it had taken its step. It's not the lists that concern me, nor getting rid of a collection of behaviors all at once. The problem is if we ant to run a collection of behaviors in parallel, all potentially accumulating internal state, how do we add/delete individual behaviors to/from that collection, without "disturbing" the others? For the sake of argument, say we have the following list of behaviours: [integral time, integral (2 * time), integral (3 * time)] We turn them into a single behavior with a list output in order to run them. After one second the output is thus [1,2,3] Now, we want to delete the second behavior, but continue to run the other two, so that the output at time 2 is [2,6] Simply mapping postprocessing that just drops the second element from the output isn't a satisfactory solution. > > let > > n :: Behavior Int > > n = > > in > > n `until` -=> n > > > > I'm not sure I got the syntax right. But the idea is that we > > output the number of left mouse button clicks, and then at some > > point, we switch to a behavior that again output the number of left > > mouse button clicks, notionally the "same" one "n". > > > > The question is, after the switch, do we observe a count that > > continues from where the old one left off, i.e. is there a > > single *shared* instance of "n" that is merely being *observed* > > from within the two "branches" of the switch, or is the counting > > behavior "n" restarted (from 0) after the switch? > > Yes, we really do get a shared n -- without doing that we certainly > would see a large space/time leak. Interesting, although I don't see why not sharing would imply a space/time leak: if the behavior is simply restarted, there is no catchup computation to do, nor any old input to hang onto, so there is neither a time nor a space-leak? Anyway, let's explore this example a bit further. Suppose "lbp" is the signal of left button presses, and that we can count them by "count lbp" Then the question is if let n :: Behavior Int n = count lbp in n `until` -=> n means the same as (count lbp) `until` -=> (count lbp) If no, then Reactive is not referentially transparent, as we manifestly cannot reason equationally. If yes, the question is how to express a counting that starts over after the switch (which sometimes is what is needed). > Yep, such Behaviors are seperated in Reactive only by the method you > create them with. I may use the `stepper` function to create a > behavior that increases in steps based on an event occurring, or I may > use fmap over time to create a continuously varying Behavior. But the question was not about events vs continuous signals. The question is, what is a behavior conceptually, and when is it started? E.g. in the example above, at what point do the various instances of "count lbp" start counting? Or are the various instances of "count lbp" actually only one? Or if you prefer, are beahviours really signals, that conceptually start running all at once at a common time 0 when the system starts? The answers regarding input behaviors like mousePosition, that "n is shared", and the need to do catchup computations all seem to indicate this. But if so, that leaves open an important question on expressivity, examplified by how to start counting from the time of a switch above, and makes if virtually impossible to avoid time and space leaks in general, at least in an embedded setting. After all, something like "count lbp" can be compiled into a function that potentially may be invoked at some point. And as long as this possibility exists, the system needs to hang on to the entire history of mouse clicks so that they can be coounted at some future point if necessary. These are all questions that go back to classical FRP, which we didn't find any good answers to back then, and which also were part of the motivation for moving to AFRP/Yampa. If Reactive has come up with better answers, that would be very exciting indeed! Best, /Henrik -- Henrik Nilsson School of Computer Science The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From mblazevic at stilo.com Thu Dec 18 13:33:57 2008 From: mblazevic at stilo.com (Mario Blazevic) Date: Thu Dec 18 13:26:32 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> Message-ID: <494A9795.9050400@stilo.com> Another implementation of coroutines is in the Streaming Component Combinators on Hackage (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/scc). In this version, a coroutine is a monad transformer that can be laid over any monad, including Id and IO. Furthermore, you can have an arbitrary number of inputs/output channels but they are restricted to communicating a single value type. From mblazevic at stilo.com Thu Dec 18 13:45:10 2008 From: mblazevic at stilo.com (Mario Blazevic) Date: Thu Dec 18 13:37:44 2008 Subject: [Haskell-cafe] Coroutines In-Reply-To: <20081218110142.215be11f@greenrd.org> References: <2f9b2d30812180137t49289cbcwe43ed810127ccc6b@mail.gmail.com> <1229594097-sup-463@ausone.local> <2f9b2d30812180226k76fa2a5fs30ee2a8c6ad0482e@mail.gmail.com> <20081218110142.215be11f@greenrd.org> Message-ID: <494A9A36.8010403@stilo.com> Robin Green wrote: > In my opinion, in Haskell, you don't need coroutines because you have > lazy evaluation. > > You example below is simply an example of a heterogenous list being > read. The simplest way to implement a heterogenous list in Haskell is > to use a tuple. Or you could use the HList package. Not quite. The consumer, useSimple, is an example of a heterogenous list being read. The producer, simple, is an example of producing a heterogenous list, value by value, on demand. You don't get that from HList for free. The difference between coroutines and lazy evaluation is that in the latter the consumer has full control. Producer supplies all the thunks, consumer picks which thunk to evaluate. Of course the producer could return a pair of first value and the rest of the computation, but then any control structure can be encoded using continuations. The question is one of notational convenience. From tom.davie at gmail.com Thu Dec 18 14:52:44 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Dec 18 14:45:24 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <494A9136.1040903@cs.nott.ac.uk> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> Message-ID: <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> Hi Henrik, On 18 Dec 2008, at 19:06, Henrik Nilsson wrote: > Hi Tom, > > > I don't think this is really true. Behaviors and Events do not > reveal > > in their type definitions any relation to any system that they may > or > > may not exist in. > > OK. So how does e.g. > > mousePoint :: Behavior Point > > get at the mouse input? unsafePerformIO? > > I.e. it is conceptually a global signal? main = adapter doSomeStuff -- Note here that different adapters provide different "UI"s. adapter :: (Behavior UI -> Behavior SomethingFixedThatYouKnowHowToInterpret) -> IO () adapter f = set up the system behaviors, pass them into f, grab the outputs, and do the "something" to render. doSomeStuff :: Behavior UI -> Behavior SomethingFixedThatYouKnowHowToInterpret > > I'm not sure I understand you clearly. If I wish to apply a > constant > function to a signal, can I not just use fmap? > > The question is why I would want to (conceptually). I'm just saying > I find it good and useful to be able to easily mix static values > and computations and signals and computations on signals. Yep, I can see that, I think we need to agree to disagree on this front, I would prefer to use fmap, or <$>, while you prefer arrow syntax. > > You would certainly need to ask Conal on this point, but I have no > > reason to suspect that b' = [1,2,3,4,5] `stepper` listE [(1,[])] > would > not deallocate the first list once it had taken its step. > > It's not the lists that concern me, nor getting rid of a collection > of behaviors all at once. The problem is if we ant to run a collection > of behaviors in parallel, all potentially accumulating internal > state, how do we add/delete individual behaviors to/from that > collection, without "disturbing" the others? > > For the sake of argument, say we have the following list of > behaviours: > > [integral time, integral (2 * time), integral (3 * time)] > > We turn them into a single behavior with a list output in order to > run them. After one second the output is thus > > [1,2,3] > > Now, we want to delete the second behavior, but continue to > run the other two, so that the output at time 2 is > > [2,6] > > Simply mapping postprocessing that just drops the second element > from the output isn't a satisfactory solution. I'm not sure why mapping the function is not satisfactory -- It would create a new Behavior, who's internals contain only the two elements from the list -- that would expose to the garbage collector that the second element has no reference from this behavior any more, and thus the whole behavior could be collected. > > Yes, we really do get a shared n -- without doing that we certainly > > would see a large space/time leak. > > Interesting, although I don't see why not sharing would imply > a space/time leak: if the behavior is simply restarted, there > is no catchup computation to do, nor any old input to hang onto, > so there is neither a time nor a space-leak? > > Anyway, let's explore this example a bit further. > > Suppose "lbp" is the signal of left button presses, and that > we can count them by > > "count lbp" > > Then the question is if > > let > n :: Behavior Int > n = count lbp > in > n `until` -=> n > > means the same as > > (count lbp) `until` -=> (count lbp) > > If no, then Reactive is not referentially transparent, as we > manifestly > cannot reason equationally. > > If yes, the question is how to express a counting that starts over > after the switch (which sometimes is what is needed). That's a yes. My first answer to how to implement the resetting counter would be someting along the lines of this, but I'm not certain it's dead right: e = (1+) <$ mouseClick e' = (const 0) <$ b = accumB 0 (e `mappend` e') i.e. b is the behavior got by adding 1 every time the mouse click event occurs, but resetting to 0 whenever occurs. > > Yep, such Behaviors are seperated in Reactive only by the method you > > create them with. I may use the `stepper` function to create a > > behavior that increases in steps based on an event occurring, or I > may > use fmap over time to create a continuously varying Behavior. > > But the question was not about events vs continuous signals. The > question is, what is a behavior conceptually, and when is it started? > E.g. in the example above, at what point do the various instances of > "count lbp" start counting? Or are the various instances of "count > lbp" > actually only one? They are indeed, only 1. > Or if you prefer, are beahviours really signals, that conceptually > start running all at once at a common time 0 when the system starts? > The answers regarding input behaviors like mousePosition, that > "n is shared", and the need to do catchup computations all seem > to indicate this. But if so, that leaves open an important > question on expressivity, examplified by how to start counting from > the time of a switch above, and makes if virtually impossible > to avoid time and space leaks in general, at least in an embedded > setting. After all, something like "count lbp" can be compiled into > a function that potentially may be invoked at some point. And as > long as this possibility exists, the system needs to hang on to > the entire history of mouse clicks so that they can be coounted > at some future point if necessary. Yes, this certainly is an ongoing problem. Currently there are certain situations in which the mouse click history is disposed of when we can show no one wants them any more, but this is not ideal. One possible solution is to make sure that all events and behaviors are updated continuously, but that may take a little more time than your solution. > These are all questions that go back to classical FRP, which we > didn't find any good answers to back then, and which also were > part of the motivation for moving to AFRP/Yampa. > > If Reactive has come up with better answers, that would be very > exciting indeed! I'm not certain that the answers are better yet. They feel more comfortable to me from a functional programming point of view, but it may yet turn out that space time leaks really are impossible to suppress. My inclination at the moment is to believe that they are though. Thanks Tom Davie From nominolo at googlemail.com Thu Dec 18 15:09:19 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Thu Dec 18 15:01:54 2008 Subject: [Haskell-cafe] Conditional properties in QuickCheck alter test data generation? In-Reply-To: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> References: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> Message-ID: <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> This bug appears to be fixed in QuickCheck 2. However, for some reason cabal-install by default only installs 1.2. You have to explicitly ask for the newer version: $ cabal install QuickCheck-2.1.0.1 -- Push the envelope. Watch it bend. From gwern0 at gmail.com Thu Dec 18 15:40:23 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Dec 18 15:33:52 2008 Subject: [Haskell-cafe] Conditional properties in QuickCheck alter test data generation? In-Reply-To: <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> References: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> Message-ID: On Thu, Dec 18, 2008 at 3:09 PM, Thomas Schilling wrote: > This bug appears to be fixed in QuickCheck 2. However, for some > reason cabal-install by default only installs 1.2. You have to > explicitly ask for the newer version: > > $ cabal install QuickCheck-2.1.0.1 cabal-install only installs 1.2 because QC 2 breaks a lot of packages (different function names, no coarbitrary, etc. IIRC). -- gwern From jacobrfoell at eaton.com Thu Dec 18 16:08:04 2008 From: jacobrfoell at eaton.com (Jake Foell) Date: Thu Dec 18 15:59:06 2008 Subject: [Haskell-cafe] Thread scheduling and GHC.Conc Message-ID: <1229634484.6299.18.camel@jrf-d620> using ghc v6.8.2 Problem: I am creating a program that forks two other lightweight threads. One of the forked threads seems to be stuck or dead after running successfully for a non-trivial amount of time. I am receiving no error messages. Questions: What is the best way to diagnose this problem? (perhaps a ghc upgrade to a version that includes processStatus?) Does the runtime system ensure that no thread will starve for processor time? My initial diagnosis: by looking at log files that this program produces, it seems that the thread in question is failing while receiving a response from a server. Here is a simplified exerpt: h <- connectTo server port appendFile file "Connection Established\n" hPutStr h httpRequestString hFlush h reply <- hGetContents h appendFile file reply If I look at the tail of file that is created, I see something similar to this: ... Connection Established here is the response... Connection Established Answers to my questions and/or any advice would be appreciated. thanks From dons at galois.com Thu Dec 18 16:20:47 2008 From: dons at galois.com (Don Stewart) Date: Thu Dec 18 16:13:14 2008 Subject: [Haskell-cafe] Thread scheduling and GHC.Conc In-Reply-To: <1229634484.6299.18.camel@jrf-d620> References: <1229634484.6299.18.camel@jrf-d620> Message-ID: <20081218212047.GC12253@scytale.galois.com> jacobrfoell: > using ghc v6.8.2 > Problem: > I am creating a program that forks two other lightweight threads. One > of the forked threads seems to be stuck or dead after running > successfully for a non-trivial amount of time. I am receiving no > error messages. > Questions: > What is the best way to diagnose this problem? (perhaps a ghc upgrade to > a version that includes processStatus?) > Does the runtime system ensure that no thread will starve for processor > time? > > My initial diagnosis: > by looking at log files that this program produces, it seems that the > thread in question is failing while receiving a response from a server. > Here is a simplified exerpt: > h <- connectTo server port > appendFile file "Connection Established\n" > hPutStr h httpRequestString > hFlush h > reply <- hGetContents h > appendFile file reply > If I look at the tail of file that is created, I see something similar > to this: > ... > Connection Established > here is the response... > Connection Established > Answers to my questions and/or any advice would be appreciated. thanks > _______________________________________________ Could you tell us more about how you compiled the program? Did you use the -threaded flag? Does your program do blocking foreign IO? -- Don From conal at conal.net Thu Dec 18 17:05:18 2008 From: conal at conal.net (Conal Elliott) Date: Thu Dec 18 16:57:54 2008 Subject: [Haskell-cafe] Re: [reactive] problem with unamb -- doesn't kill enough threads In-Reply-To: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> References: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> Message-ID: (I'm broadening the discussion to include haskell-cafe.) Andy -- What do you mean by "handling all thread forking locally"? - Conal On Thu, Dec 18, 2008 at 1:57 PM, Andy Gill wrote: > Conal, et. al, > I was looking for exactly this about 6~9 months ago. I got the suggestion > to pose it as a challenge > to the community by Duncan Coutts. What you need is thread groups, where > for a ThreadId, you can send a signal > to all its children, even missing generations if needed. > > I know of no way to fix this at the Haskell level without handling > all thread forking locally. > > Perhaps a ICFP paper about the pending implementation :-) but I'm not sure > about the research content here. > > Again, there is something deep about values with lifetimes. > > Andy Gill > > > On Dec 18, 2008, at 3:43 PM, Conal Elliott wrote: > > I realized in the shower this morning that there's a serious flaw in my > unamb implementation as described in > http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice. > I'm looking for ideas for fixing the flaw. Here's the code for racing > computations: > > race :: IO a -> IO a -> IO a > a `race` b = do v <- newEmptyMVar > ta <- forkPut a v > tb <- forkPut b v > x <- takeMVar v > killThread ta > killThread tb > return x > > forkPut :: IO a -> MVar a -> IO ThreadId > forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler `catch` > bhandler) > where > uhandler (ErrorCall "Prelude.undefined") = return () > uhandler err = throw err > bhandler BlockedOnDeadMVar = return () > > The problem is that each of the threads ta and tb may have spawned other > threads, directly or indirectly. When I kill them, they don't get a chance > to kill their sub-threads. > > Perhaps I want some form of garbage collection of threads, perhaps akin to > Henry Baker's paper "The Incremental Garbage Collection of Processes". As > with memory GC, dropping one consumer would sometimes result is cascading > de-allocations. That cascade is missing from my implementation. > > Or maybe there's a simple and dependable manual solution, enhancing the > method above. > > Any ideas? > > - Conal > > > _______________________________________________ > Reactive mailing list > Reactive@haskell.org > http://www.haskell.org/mailman/listinfo/reactive > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081218/138e5c9d/attachment.htm From jefferson.r.heard at gmail.com Thu Dec 18 17:12:18 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Dec 18 17:04:54 2008 Subject: [Haskell-cafe] ANN: Thingie-0.80 Message-ID: <4165d3a70812181412w3890a83etb89c250bf6cc8da2@mail.gmail.com> I need a better name for this, but I have software, so I shall release it with a dumb name. Thingie has just been uploaded to hackage. It is a library for creating 2D visualizations in a purely functional manner. It supports static visualizations and animation, and like most vis libraries, can probably do games as well as simple viz graphics. The backend uses Cairo for rendering, but I'm looking to port it to OpenGL/GLUT for systems where Gtk/Cairo is hard to get working (i.e. OS/X). The idea is that you create a graph of objects or function that return objects and the library renders them for you in 2D. Right now, there's one thing I would like to add to the system above all other things: The interactive system has the concept of a tracked program state that is threaded through the graph. This state is defined by a UIState class, and any state (which is a record object) must be an instance of UIState and provide the system with a certain number of getters and setters for basic bits of state. I would like to use Template Haskell to help create/derive these structures. Does anyone on the list want to help with that? Here are two examples. Each draws a smiley face, and the interactive one tracks your mouse with a little red ball. First the non-interactive: module Main where import Graphics.Rendering.Thingie.Primitives import Graphics.Rendering.Thingie.Cairo import qualified Graphics.Rendering.Cairo as Cairo smiley = Context [FillRGBA 0 0 0 0, Operator Cairo.OperatorClear] $ Group [Draw rectangleFilled{ topleft=Point2D 0 0, width=200, height=200 } ,Context [FillRGBA 1 1 0 1, OutlineRGBA 0 0 0 1, Translate 100 100, Operator Cairo.OperatorOver] $ Group [Draw arc{ radius=100, filled=True } ,Context [FillRGBA 0 0 0 1] $ Group [Draw arc{ center=Point2D (-33) (-33), radius=10, filled=True } ,Draw arc{ center=Point2D 33 (-33), radius=10, filled=True } ,Draw arc{ angle1=degrees 30, angle2=degrees 150, radius=70 }]]] main = renderObjectToPNG "smiley.png" 200 200 smiley ----- Now the interactive: import Graphics.Rendering.Thingie.Interactive import Graphics.Rendering.Thingie.BasicUIState import Graphics.Rendering.Thingie.Cairo import Graphics.Rendering.Thingie.Primitives import qualified Graphics.Rendering.Cairo as Cairo smiley = Context [FillRGBA 0 0 0 0, Operator Cairo.OperatorClear] $ Group [Draw rectangleFilled{ topleft=Point2D 0 0, width=200, height=200 } ,Context [FillRGBA 1 1 0 1, OutlineRGBA 0 0 0 1, Translate 100 100, Operator Cairo.OperatorOver] $ Group [Draw arc{ radius=100, filled=True } ,Context [FillRGBA 0 0 0 1] $ Group [Draw arc{ center=Point2D (-33) (-33), radius=10, filled=True } ,Draw arc{ center=Point2D 33 (-33), radius=10, filled=True } ,Draw arc{ angle1=degrees 30, angle2=degrees 150, radius=70 }]]] undercursor uistate = Context [FillRGBA 1 0 0 1] $ Draw arcFilled{ center=mousePosition uistate, radius=5 } scene = [StaticElement smiley (Rect2D 0 0 0 0) ,UnboundedElement undercursor] main = simpleMotionSensitiveGui defaultBasicUIState scene "smiley face" From jefferson.r.heard at gmail.com Thu Dec 18 17:45:57 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Dec 18 17:38:32 2008 Subject: [Haskell-cafe] Re: ANN: Thingie-0.80 In-Reply-To: <4165d3a70812181412w3890a83etb89c250bf6cc8da2@mail.gmail.com> References: <4165d3a70812181412w3890a83etb89c250bf6cc8da2@mail.gmail.com> Message-ID: <4165d3a70812181445w331215c3jabfcd4a1ce6675c7@mail.gmail.com> Make that version 0.81 -- added in a module that exports all the other modules except BasicUIState. On Thu, Dec 18, 2008 at 5:12 PM, Jeff Heard wrote: > I need a better name for this, but I have software, so I shall release > it with a dumb name. Thingie has just been uploaded to hackage. It > is a library for creating 2D visualizations in a purely functional > manner. It supports static visualizations and animation, and like > most vis libraries, can probably do games as well as simple viz > graphics. The backend uses Cairo for rendering, but I'm looking to > port it to OpenGL/GLUT for systems where Gtk/Cairo is hard to get > working (i.e. OS/X). The idea is that you create a graph of objects > or function that return objects and the library renders them for you > in 2D. > > Right now, there's one thing I would like to add to the system above > all other things: The interactive system has the concept of a tracked > program state that is threaded through the graph. This state is > defined by a UIState class, and any state (which is a record object) > must be an instance of UIState and provide the system with a certain > number of getters and setters for basic bits of state. I would like > to use Template Haskell to help create/derive these structures. Does > anyone on the list want to help with that? > > Here are two examples. Each draws a smiley face, and the interactive > one tracks your mouse with a little red ball. > First the non-interactive: > > module Main where > > import Graphics.Rendering.Thingie.Primitives > import Graphics.Rendering.Thingie.Cairo > import qualified Graphics.Rendering.Cairo as Cairo > > smiley = Context [FillRGBA 0 0 0 0, Operator Cairo.OperatorClear] $ > Group [Draw rectangleFilled{ topleft=Point2D 0 0, > width=200, height=200 } > ,Context [FillRGBA 1 1 0 1, OutlineRGBA 0 0 0 > 1, Translate 100 100, Operator Cairo.OperatorOver] $ > Group [Draw arc{ radius=100, filled=True } > ,Context [FillRGBA 0 0 0 1] $ > Group [Draw arc{ > center=Point2D (-33) (-33), radius=10, filled=True } > ,Draw arc{ > center=Point2D 33 (-33), radius=10, filled=True } > ,Draw arc{ > angle1=degrees 30, angle2=degrees 150, radius=70 }]]] > > main = renderObjectToPNG "smiley.png" 200 200 smiley > > > ----- > > Now the interactive: > > > import Graphics.Rendering.Thingie.Interactive > import Graphics.Rendering.Thingie.BasicUIState > import Graphics.Rendering.Thingie.Cairo > import Graphics.Rendering.Thingie.Primitives > > import qualified Graphics.Rendering.Cairo as Cairo > > smiley = Context [FillRGBA 0 0 0 0, Operator Cairo.OperatorClear] $ > Group [Draw rectangleFilled{ topleft=Point2D 0 0, > width=200, height=200 } > ,Context [FillRGBA 1 1 0 1, OutlineRGBA 0 0 0 > 1, Translate 100 100, Operator Cairo.OperatorOver] $ > Group [Draw arc{ radius=100, filled=True } > ,Context [FillRGBA 0 0 0 1] $ > Group [Draw arc{ > center=Point2D (-33) (-33), radius=10, filled=True } > ,Draw arc{ > center=Point2D 33 (-33), radius=10, filled=True } > ,Draw arc{ > angle1=degrees 30, angle2=degrees 150, radius=70 }]]] > > undercursor uistate = Context [FillRGBA 1 0 0 1] $ > Draw arcFilled{ center=mousePosition > uistate, radius=5 } > > scene = [StaticElement smiley (Rect2D 0 0 0 0) > ,UnboundedElement undercursor] > > main = simpleMotionSensitiveGui defaultBasicUIState scene "smiley face" > From martijn at van.steenbergen.nl Thu Dec 18 18:17:19 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Dec 18 18:09:54 2008 Subject: [Haskell-cafe] When using functional dependencies to combine... Message-ID: <494AD9FF.5090002@van.steenbergen.nl> Good evening everyone, My program reads: > module Boom where > > import Control.Monad.State > > type SucParser s = StateT [s] [] > > newtype WithUnit s a = WithUnit (SucParser s (a, ())) > > foo :: SucParser s [s] > foo = get > > bar :: WithUnit s [s] > bar = WithUnit get The compiler complains: Boom.hs:13:0: Couldn't match expected type `([s], ())' against inferred type `[s]' When using functional dependencies to combine MonadState s (StateT s m), arising from the instance declaration at MonadState ([s], ()) (StateT [s] []), arising from a use of `get' at Boom.hs:13:15-17 When generalising the type(s) for `bar' I'm wondering if I'm making a silly mistake or if there's something less trivial going on here. Could someone please explain the error and give a hint on how to fix it? Thanks much. :-) Martijn. From duncan.coutts at worc.ox.ac.uk Thu Dec 18 18:55:44 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 18 18:48:19 2008 Subject: [Haskell-cafe] Conditional properties in QuickCheck alter test data generation? In-Reply-To: <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> References: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> Message-ID: <1229644545.10115.712.camel@localhost> On Thu, 2008-12-18 at 20:09 +0000, Thomas Schilling wrote: > This bug appears to be fixed in QuickCheck 2. However, for some > reason cabal-install by default only installs 1.2. You have to > explicitly ask for the newer version: > > $ cabal install QuickCheck-2.1.0.1 Or more generally: $ cabal install 'quickcheck >= 2' so you don't have to know exactly which version. I'm not quite sure what to do about these cases where we've added a global preference to keep old packages working but where it conflicts with the principle of least surprise. We don't necessarily want to just ignore the preference when the user asks for it on the command line because that prevents maintainers using it to allow stable and experimental versions of a package to be on hackage simultaneously. However QuickCheck seems to be a case where people now expect to use QC-2, but old packages that don't specify a version typically only work with QC-1.x. Duncan From schlepptop at henning-thielemann.de Thu Dec 18 19:15:31 2008 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Thu Dec 18 19:03:06 2008 Subject: Fwd: [Haskell-cafe] Haskell as a religion In-Reply-To: References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> Message-ID: <494AE7A3.3000306@henning-thielemann.de> Alberto G. Corona schrieb: > But many features need other features. For example, the option to use > referential transparency will be common in future languages for > multicore programming purposes. This creates the problem of separating > side-effect-free code from side-effect code. In C/C++ referential transparent functions code can be declared by appending a 'const' to the prototype, right? > I think that once the average programmer start to use one or two of > these features, he will feel a bit frustrated if its language don?t have > all the others, specially if he know haskell. Probably, he will use > haskell for fun. This is the best way for the takeover of the industry, > because this has been so historically. Extrapolating the habit of programmers from the past to the future, I predict that Haskell can only become a mainstream language once there is a cleaner, simpler, safer and more powerful programming language than Haskell. From max.rabkin at gmail.com Thu Dec 18 19:13:52 2008 From: max.rabkin at gmail.com (Max Rabkin) Date: Thu Dec 18 19:06:30 2008 Subject: [Haskell-cafe] Conditional properties in QuickCheck alter test data generation? In-Reply-To: <1229644545.10115.712.camel@localhost> References: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> <1229644545.10115.712.camel@localhost> Message-ID: On Thu, Dec 18, 2008 at 3:55 PM, Duncan Coutts wrote: > However QuickCheck seems to be a case where > people now expect to use QC-2, but old packages that don't specify a > version typically only work with QC-1.x. Can't we just fix those .cabal files? --Max From max.rabkin at gmail.com Thu Dec 18 19:15:19 2008 From: max.rabkin at gmail.com (Max Rabkin) Date: Thu Dec 18 19:07:53 2008 Subject: Fwd: [Haskell-cafe] Haskell as a religion In-Reply-To: <494AE7A3.3000306@henning-thielemann.de> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> <494AE7A3.3000306@henning-thielemann.de> Message-ID: On Thu, Dec 18, 2008 at 4:15 PM, Henning Thielemann wrote: > Extrapolating the habit of programmers from the past to the future, I > predict that Haskell can only become a mainstream language once there is > a cleaner, simpler, safer and more powerful programming language than > Haskell. And so, finally, we find the fatal flaw in trying to create the ultimate programming language. --Max From ok at cs.otago.ac.nz Thu Dec 18 19:18:21 2008 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Dec 18 19:10:57 2008 Subject: [Haskell-cafe] Haskell, successing crossplatform API standart In-Reply-To: <21067779.post@talk.nabble.com> References: <20742743.post@talk.nabble.com> <5CDE013B-1F09-48A9-8946-93959E911E52@gmail.com> <21067779.post@talk.nabble.com> Message-ID: On 18 Dec 2008, at 7:41 pm, Belka wrote: > Oh, but JSON doesn't seem to support tree-structured data... Sure it does. In Haskell terms, data JSON = JSON_Number Double -- not entirely clear, actually | JSON_String String -- Unicode | JSON_Array [JSON] -- order matters | JSON_Object [(String,JSON)] -- Unicode keys, order no matter It supports trees well enough that encoding XML as JSON is trivial. To a first approximation, data XML = XML_CData String | XML_Element String [(String,String)] [XML] So, xml_to_json (XML_CData s) = JSON_String s xml_to_json (XML_Elment name atts children) = JSON_Object [("n", JSON_String name), ("a", JSON_Object [(k,JSON_STRING v) | (k,v) <- atts]), ("c", JSON_Array (map xml_to_json children))] One can handle the other aspects of XML, I just couldn't be bothered. Converting JSON that represents XML to XML is straightforward. Of course the converse is true too. json_to_xml (JSON_Number x) = XML_Element "n" [] XML_CData (show x) json_to_xml (JSON_String s) = XML_Element "s" [] XML_CData s json_to_xml (JSON_Array a) = XML_Element "a" [] map json_to_xml a json_to_xml (JSON_Object o) = XML_Element "o" [] [XML_Element "e" [("k",k)] (json_to_xml v) | (k,v) <- o] Again, converting XML that represents JSON to JSON is straightward, I just don't need to show it to make the point. Also obviously, you might as well use Lisp s-expressions. If you have a choice between XML and JSON, it may be worth remembering that JSON is *far* easier to parse. I would expect a JSON parser to be faster, and more importantly, I would expect it to be more reliable. From briqueabraque at yahoo.com Thu Dec 18 19:18:37 2008 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Thu Dec 18 19:11:25 2008 Subject: [Haskell-cafe] Re: Detecting system endianness In-Reply-To: <200812181403.40459.holgersiegel74@yahoo.de> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> <200812181403.40459.holgersiegel74@yahoo.de> Message-ID: I actually don't need a pure function, IO is OK. I'll try something in these lines. It doesn't build yet, with an error message I'll probably take a few months to understand: Couldn't match expected type `forall a. (Storable a) => a -> IO a' against inferred type `a -> IO a' Thanks, Maur?cio ----- import Control.Monad ; import Foreign ; import Foreign.C ; type CUInt16 = CUShort ; type CUInt8 = CChar ; littleEndianToHost,hostToLittleEndian :: forall a. (Storable a ) => a -> IO a ; (littleEndianToHost,hostToLittleEndian) = (f,f) where { f :: forall a. ( Storable a ) => a -> IO a ; f a = with ( 0x0102 :: CUInt16 ) $ \p -> do { firstByte <- peek ( castPtr p :: Ptr CUInt8 ) ; littleEndian <- return $ firstByte == 0x02 ; halfSize <- return $ div ( alignment a ) 2; reverse <- with a $ \val -> zipWithM (swapByte (castPtr val :: Ptr CUInt8)) [0..halfSize-1] [halfSize..2*halfSize-1] >> peek val ; return $ if littleEndian then a else reverse ; } ; swapByte p n1 n2 = do { v1 <- peekElemOff p n1 ; v2 <- peekElemOff p n2 ; pokeElemOff p n1 v2 ; pokeElemOff p n2 v1 } >> return () } ----- > On Thursday 18 December 2008 13:40:47 Ryan Ingram wrote: >> Actually, this is probably safer: >> >> import Foreign.Marshal.Alloc >> import Foreign.Ptr >> import Foreign.Storable >> import Data.Word >> import System.IO.Unsafe >> >> endianCheck = unsafePerformIO $ alloca $ \p -> poke p (0x01020304 :: >> Word32) >> peek (castPtr p :: Ptr Word8) >> >> littleEndian = endianCheck == 4 >> bigEndian = endianCheck == 1 >> >> (...) From isaacdupree at charter.net Thu Dec 18 19:25:28 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Dec 18 19:18:02 2008 Subject: Fwd: [Haskell-cafe] Haskell as a religion In-Reply-To: <494AE7A3.3000306@henning-thielemann.de> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> <494AE7A3.3000306@henning-thielemann.de> Message-ID: <494AE9F8.3080709@charter.net> Henning Thielemann wrote: > Alberto G. Corona schrieb: >> But many features need other features. For example, the option to use >> referential transparency will be common in future languages for >> multicore programming purposes. This creates the problem of separating >> side-effect-free code from side-effect code. > > In C/C++ referential transparent functions code can be declared by > appending a 'const' to the prototype, right? not quite. GCC allows __attribute__((__const__)) or __attribute__((__pure__)), to declare that, though (one of them allows reading global variables, the other doesn't, I forget which). In C and C++ per standard, "const" can only be applied to types, e.g. function arguments (including C++'s implicit *this, via funny location of "const"). Maybe C99 made up an additional way to use it, as it introduced "restrict", I forget -Isaac From duncan.coutts at worc.ox.ac.uk Thu Dec 18 19:38:09 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Dec 18 19:30:48 2008 Subject: [Haskell-cafe] Conditional properties in QuickCheck alter test data generation? In-Reply-To: References: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> <1229644545.10115.712.camel@localhost> Message-ID: <1229647089.10115.719.camel@localhost> On Thu, 2008-12-18 at 16:13 -0800, Max Rabkin wrote: > On Thu, Dec 18, 2008 at 3:55 PM, Duncan Coutts > wrote: > > However QuickCheck seems to be a case where > > people now expect to use QC-2, but old packages that don't specify a > > version typically only work with QC-1.x. > > Can't we just fix those .cabal files? We can certainly ask maintainers to specify the QC dependency properly when they next upload. We do not yet have a mechanism to update .cabal file dependencies on hackage after a package has been uploaded, though we have been pondering adding such a facility for a while. Duncan From nhn at Cs.Nott.AC.UK Thu Dec 18 20:05:11 2008 From: nhn at Cs.Nott.AC.UK (Henrik Nilsson) Date: Thu Dec 18 20:01:51 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> Message-ID: <494AF347.9010809@cs.nott.ac.uk> Hi Tom, > I'm not sure why mapping the function is not satisfactory -- It would > create a new Behavior, who's internals contain only the two elements > from the list -- that would expose to the garbage collector that the > second element has no reference from this behavior any more, and thus > the whole behavior could be collected. We must be talking at cross purposes here: there is no way that deleting the *output* from one of the behaviours from a list of outputs would cause the underlying behavior whose output no longer is observed to be garbage collected. After all, that list of three numbers is just a normal value: why should removing one of its elements, so to speak, affect the producer of the list? But if we have a list of running behaviors or signals, and that list is changed, then yes, of course we get the desired behavior (this is what Yampa does). So maybe that's what you mean? > That's a yes. My first answer to how to implement the resetting > counter would be someting along the lines of this, but I'm not certain > it's dead right: > > e = (1+) <$ mouseClick > e' = (const 0) <$ > b = accumB 0 (e `mappend` e') > > i.e. b is the behavior got by adding 1 every time the mouse click > event occurs, but resetting to 0 whenever occurs. Hmm. Looks somewhat complicated to me. Anyway, it doesn't really answer the fundamental question: how does one start a behavior/signal function at a particular point in time? I consider the fact that Yampa, through supporting both signals and signal functions, provides simple yet flexible answers to the question when a signal function starts to be one of its key strengths over Classical FRP and maybe then also over Reactive. Best, /Henrik -- Henrik Nilsson School of Computer Science The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From daniel.is.fischer at web.de Thu Dec 18 20:20:47 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Dec 18 20:10:52 2008 Subject: [Haskell-cafe] When using functional dependencies to combine... In-Reply-To: <494AD9FF.5090002@van.steenbergen.nl> References: <494AD9FF.5090002@van.steenbergen.nl> Message-ID: <200812190220.47801.daniel.is.fischer@web.de> Am Freitag, 19. Dezember 2008 00:17 schrieb Martijn van Steenbergen: > Good evening everyone, > > My program reads: > > module Boom where > > > > import Control.Monad.State > > > > type SucParser s = StateT [s] [] > > > > newtype WithUnit s a = WithUnit (SucParser s (a, ())) > > > > foo :: SucParser s [s] > > foo = get > > > > bar :: WithUnit s [s] > > bar = WithUnit get > > The compiler complains: > > Boom.hs:13:0: > Couldn't match expected type `([s], ())' > against inferred type `[s]' > When using functional dependencies to combine > MonadState s (StateT s m), > arising from the instance declaration at > MonadState ([s], ()) (StateT [s] []), > arising from a use of `get' at Boom.hs:13:15-17 > When generalising the type(s) for `bar' > > I'm wondering if I'm making a silly mistake or if there's something less > trivial going on here. Could someone please explain the error and give a > hint on how to fix it? class MonadState s m | m -> s where get :: m s ... For SucParser, get :: StateT [s] [] [s]. To wrap it in WithUnit, it would need type StateT [s] [] (([s],()),[s]) Easy fix: bar :: WithUnit s [s] bar = WithUnit $ do s <- get return (s,()) Better define liftUnit :: SucParser s a -> WithUnit s a liftUnit m = WithUnit $ do a <- m return (a,()) and bar = liftUnit get Or make WithUnit more general (working with arbitrary monads) and give it a MonadTrans instance. > > Thanks much. :-) > > Martijn. From daniel.is.fischer at web.de Thu Dec 18 20:27:26 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Dec 18 20:17:32 2008 Subject: [Haskell-cafe] When using functional dependencies to combine... In-Reply-To: <200812190220.47801.daniel.is.fischer@web.de> References: <494AD9FF.5090002@van.steenbergen.nl> <200812190220.47801.daniel.is.fischer@web.de> Message-ID: <200812190227.26282.daniel.is.fischer@web.de> Am Freitag, 19. Dezember 2008 02:20 schrieb Daniel Fischer: > For SucParser, > get :: StateT [s] [] [s]. > To wrap it in WithUnit, it would need type > StateT [s] [] (([s],()),[s]) Oops, that should be StateT [s] [] ([s],()), of course. From dpiponi at gmail.com Thu Dec 18 21:02:02 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Thu Dec 18 20:54:39 2008 Subject: Fwd: [Haskell-cafe] Haskell as a religion In-Reply-To: <494AE7A3.3000306@henning-thielemann.de> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> <494AE7A3.3000306@henning-thielemann.de> Message-ID: <625b74080812181802w43916fe4o64ec1a41f8ee9db4@mail.gmail.com> On Thu, Dec 18, 2008 at 4:15 PM, Henning Thielemann wrote: > In C/C++ referential transparent functions code can be declared by > appending a 'const' to the prototype, right? For one thing, some fields in a const C++ object can be explicitly set mutable. mutable is sometimes used in C++ a similar way to unsafePerformIO in Haskell. You have something that uses mutability in its internals but that mutability shouldn't be observable to the caller. In both cases you have no means of actually ensuring that the mutability is actually unobservable. -- Dan From wren at freegeek.org Thu Dec 18 21:23:29 2008 From: wren at freegeek.org (wren ng thornton) Date: Thu Dec 18 21:16:04 2008 Subject: intimidating terminology (was: Re: [Haskell-cafe] Time for a new logo?) In-Reply-To: <49497CB2.2030507@btinternet.com> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> Message-ID: <494B05A1.4070306@freegeek.org> quoth Andrew Coppin: > quoth Tristan Seligmann: > > quoth Andrew Coppin: > > > Sure, there are many concepts in Haskell which just aren't found > > > anywhere else. But monads? Catamorphisms? Coroutines? Couldn't we > > > think up some less intimidating terminology? > > > > The problem is that "less intimidating" terminology generally seems to > > mean inaccurate or misleading terminology. > > I'm not sure I agree with that. > > Sure, simplifying things *can* make them less precise. But I don't > believe it is always necessarily so. And I think we could try a little > bit harder here. (Nothing too radical, just some small changes.) Consider the humble catamorphism (and anamorphism). Can you think of any simple, descriptive, non-ambiguous name for this pattern other than the technical name? An oft used name is "fold" (and "unfold") which is simple, possibly descriptive, but certainly ambiguous. For example: the fold/unfold names are used as jargon for optimization ---in compilers for logic languages and query planning for databases--- for inlining functions and then 'outlining' parts after doing some reorganization. There are other technical uses which are just as different. The problem with simple terms for jargon is that they're all taken. When we take everyday terms like "fold", "set", "list", "tree", "category", "type", "kind", "sort", "variety", "domain", "group", et cetera and reappropriate them for technical use there are two problems. The first is that all of the simple everyday terms have already been appropriated time and again, so using it will often be ambiguous. The second is that the technical meaning often does not expressly match the daily meaning, which in turn means that these terms will often be confusing or used casually in a way that confuses the daily and technical meanings. It's all well and good for terminology to be non-intimidating, but for technical terminology I think there must be a high premium on correctness as well. Reappropriating terms which have fallen into disuse for their original meanings (e.g. monad) or which are taken or invented from languages the audience is unlikely to be familiar with (e.g. catamorphism) ensures that we don't have to worry about baggage associated with those words. This is good because it means there won't be conflicts of meaning, but it's bad because it means the audience can't intuit an approximate meaning. Pedantic as I am wont to be, I think the benefit outweighs the detriment, but YMMV. -- Live well, ~wren From conal at conal.net Thu Dec 18 21:52:42 2008 From: conal at conal.net (Conal Elliott) Date: Thu Dec 18 21:45:15 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: References: Message-ID: Hi Tony, Reactive so far has focused mainly on events and functions of time (behaviors/signals), while Yampa on transformations between signals. I'm in the process of building a higher-level interface with some semantic similarity to the arrow/Yampa style. See recent posts at http://conal.net/blog to get some flavor of where I'm going. The post "Why classic FRP does not fit interactive behavior" in particular mentions part of my motivation for doing something different from both classic FRP and Yampa. - Conal 2008/12/16 Tony Hannan > Hello, > > Can someone describe the advantages and disadvantages of the Yampa library > versus the Reactive library for functional reactive programming, or point me > to a link. > > Thanks, > Tony > > P.S. It is hard to google for Yampa and Reactive together because > "reactive" as in "function reactive programming" always appears with Yampa > > > _______________________________________________ > 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/20081218/f87be17f/attachment.htm From wren at freegeek.org Thu Dec 18 22:03:59 2008 From: wren at freegeek.org (wren ng thornton) Date: Thu Dec 18 21:56:32 2008 Subject: [Haskell-cafe] lengthOP rewrite rules In-Reply-To: <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> References: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> Message-ID: <494B0F1F.7070603@freegeek.org> Luke Palmer wrote: > This does not answer your question, but you can solve this problem without > rewrite rules by having length return a lazy natural: > > data Nat = Zero | Succ Nat > > And defining lazy comparison operators on it. And if you want to go that route, then see Data.List.Extras.LazyLength from list-extras[1]. Peano integers are quite inefficient, but this library does the same transform efficiently. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/list-extras > Of course you cannot replace usages of Prelude.length. But I am really not > in favor of rules which change semantics, even if they only make things less > strict. My argument is the following. I may come to rely on such > nonstrictness as in: > > bad xs = (length xs > 10, length xs > 20) > > bad [1..] will return (True,True). However, if I do an obviously > semantics-preserving refactor: > > bad xs = (l > 10, l > 20) > where > l = length xs > > My semantics are not preserved: bad [1..] = (_|_, _|_) (if/unless the > compiler is clever, in which case my semantics depend on the compiler's > cleverness which is even worse) Data.List.Extras.LazyLength does have rewrite rules to apply the lazy versions in place of Prelude.length where it can. My justification is two-fold. First is that for finite lists the semantics are identical but the memory behavior is strictly better. Second is that for non-finite lists the termination behavior is strictly better. It's true that refactoring can disable either point, and that can alter semantics in the latter case. Since the module is explicit about having these rules, I would say that users should remain aware of the fact that they're taking advantage of them or they should use the explicit lengthBound or lengthCompare functions instead. -- Live well, ~wren From wren at freegeek.org Thu Dec 18 22:35:40 2008 From: wren at freegeek.org (wren ng thornton) Date: Thu Dec 18 22:28:12 2008 Subject: [Haskell-cafe] Detecting system endianness In-Reply-To: <200812181403.40459.holgersiegel74@yahoo.de> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> <200812181403.40459.holgersiegel74@yahoo.de> Message-ID: <494B168C.8020900@freegeek.org> In a similar vein, is there already a function available to give the size of Word in bytes? Or should I write the usual Ptr conversion tricks to figure it out? Holger Siegel wrote: > On Thursday 18 December 2008 13:40:47 Ryan Ingram wrote: >> Actually, this is probably safer: >> >> import Foreign.Marshal.Alloc >> import Foreign.Ptr >> import Foreign.Storable >> import Data.Word >> import System.IO.Unsafe >> >> endianCheck = unsafePerformIO $ alloca $ \p -> poke p (0x01020304 :: >> Word32) >> peek (castPtr p :: Ptr Word8) >> >> littleEndian = endianCheck == 4 >> bigEndian = endianCheck == 1 >> >> -- ryan > > > Using modules Data.Binary, Data.Binary.Put and Data.Word, you can define > > littleEndian = (decode $ runPut $ putWord16host 42 :: Word8) == 42 > > Under the hood, it also uses peek and poke, but it looks a bit more > functional. -- Live well, ~wren From dons at galois.com Thu Dec 18 23:07:00 2008 From: dons at galois.com (Don Stewart) Date: Thu Dec 18 22:59:26 2008 Subject: [Haskell-cafe] Detecting system endianness In-Reply-To: <494B168C.8020900@freegeek.org> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> <200812181403.40459.holgersiegel74@yahoo.de> <494B168C.8020900@freegeek.org> Message-ID: <20081219040700.GA14283@scytale.galois.com> Foreign.Storable.sizeOf wren: > In a similar vein, is there already a function available to give the > size of Word in bytes? Or should I write the usual Ptr conversion tricks > to figure it out? > > > > Holger Siegel wrote: > >On Thursday 18 December 2008 13:40:47 Ryan Ingram wrote: > >>Actually, this is probably safer: > >> > >>import Foreign.Marshal.Alloc > >>import Foreign.Ptr > >>import Foreign.Storable > >>import Data.Word > >>import System.IO.Unsafe > >> > >>endianCheck = unsafePerformIO $ alloca $ \p -> poke p (0x01020304 :: > >>Word32) >> peek (castPtr p :: Ptr Word8) > >> > >>littleEndian = endianCheck == 4 > >>bigEndian = endianCheck == 1 > >> > >> -- ryan > > > > > >Using modules Data.Binary, Data.Binary.Put and Data.Word, you can define > > > > littleEndian = (decode $ runPut $ putWord16host 42 :: Word8) == 42 > > > >Under the hood, it also uses peek and poke, but it looks a bit more > >functional. > > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From porges at porg.es Thu Dec 18 23:09:12 2008 From: porges at porg.es (George Pollard) Date: Thu Dec 18 23:01:55 2008 Subject: [Haskell-cafe] Detecting system endianness In-Reply-To: <494B168C.8020900@freegeek.org> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> <200812181403.40459.holgersiegel74@yahoo.de> <494B168C.8020900@freegeek.org> Message-ID: <1229659752.32102.6.camel@porges-laptop> On Thu, 2008-12-18 at 22:35 -0500, wren ng thornton wrote: > In a similar vein, is there already a function available to give the > size of Word in bytes? Or should I write the usual Ptr conversion tricks > to figure it out? How about this: (`div` 8) $ ceiling $ logBase 2 $ fromIntegral (maxBound :: Word) Could write an integral log_2 function to make it nicer :) - George -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/a107d9c8/attachment.bin From dons at galois.com Fri Dec 19 00:10:07 2008 From: dons at galois.com (Don Stewart) Date: Fri Dec 19 00:02:29 2008 Subject: [Haskell-cafe] RWH book club Message-ID: <20081219051007.GC14283@scytale.galois.com> Matt Podwysocki set up a Real World Haskell book club, http://groups.google.com/group/real-world-haskell-book-club (a mailing list on google groups), with already some 200 members discussing typical new user Haskell questions. Feel free to join if you like talking about Haskell, or teaching new users. -- Don From kevin at ksvanhorn.com Fri Dec 19 00:43:07 2008 From: kevin at ksvanhorn.com (Kevin Van Horn) Date: Fri Dec 19 00:35:42 2008 Subject: [Haskell-cafe] Conditional properties in QuickCheck alter test data generation? In-Reply-To: <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> References: <88778080-42E1-4DBC-BB55-5FC253227F88@ksvanhorn.com> <916b84820812181209s5d9f74adq86e374daf5ef8805@mail.gmail.com> Message-ID: <515FBDA9-6421-41CE-BF86-110F12681AF4@ksvanhorn.com> Thanks. That took care of the problem with quickCheck, but now I have another problem: verboseCheck has disappeared! It doesn't seem to exist anymore in QuickCheck 2. I've looked over all the documentation I can find, but I can't any mention of this change. What replaces the functionality of verboseCheck in QuickCheck 2? On Dec 18, 2008, at 1:09 PM, Thomas Schilling wrote: > This bug appears to be fixed in QuickCheck 2. However, for some > reason cabal-install by default only installs 1.2. You have to > explicitly ask for the newer version: > > $ cabal install QuickCheck-2.1.0.1 > > > -- > Push the envelope. Watch it bend. From ashley at semantic.org Fri Dec 19 03:10:37 2008 From: ashley at semantic.org (Ashley Yakeley) Date: Fri Dec 19 03:03:29 2008 Subject: [Haskell-cafe] Logos of Other Languages Message-ID: I browsed around a bit for logos from other languages... Python http://www.python.org/images/python-logo.gif The "snake pair" is visually interesting while still remaining simple. The typeface is unusual and yet clean and humanistic. The logo is only slightly marred by the "TM". Overall, elegant and appealing. A. Caml http://caml.inria.fr/styles/modern/title-en.gif This is actually more of a heading than a logo: it continues to the right edge of the page to close the oval. The typeface is readable, but the text is a bit verbose, spelling out "The Caml Language" with a visual nod to its ML roots. B+. Ruby http://www.ruby-lang.org/images/logo.gif An ordinary book typeface with an ordinary picture of an ordinary ruby. And the strapline "A Programmer's Best Friend" is vague and uninspired. Bland, but at least inoffensive. C. Perl http://upload.wikimedia.org/wikipedia/en/e/e0/Programming-republic-of-perl.png I'm not sure if this is "the Perl logo" or "O'Reilly's Perl logo", but it's ugly, busy, difficult to read and a bit obscure. The title "PROGRAMMING REPUBLIC OF" also lends an air of snotty pretension. D. Apple Dylan http://osteele.com/projects/images/Dylan.logo-thumb.png Arty, abstract, vaguely Hermitian, but a bit corporate. Easy to make a website favicon from, but the actual word "Dylan" is not strictly included. A-. All of these get one thing right that the current and most of the proposed Haskell logos do not: they don't make any reference to the syntax of the language itself. Doing so seems to miss the point of a logo: it's supposed to appeal visually, rather than semantically. So I'd like to see some submissions that don't use lambdas. -- Ashley Yakeley Seattle, WA From lennart at augustsson.net Fri Dec 19 04:13:20 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri Dec 19 04:05:52 2008 Subject: intimidating terminology (was: Re: [Haskell-cafe] Time for a new logo?) In-Reply-To: <494B05A1.4070306@freegeek.org> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> <494B05A1.4070306@freegeek.org> Message-ID: When accurate names for Haskell concepts already exist we should use them (as we have tried in the past). There has been too much invention of misleading terminology in computing already. If some people can't handle things having the right names, well, maybe they should try another language. (What would happen if we used the new name principle, e.g., in cooking? "Oh, cinnamon is a difficult name, I'll call it tangy spice instead.") -- Lennart On Fri, Dec 19, 2008 at 2:23 AM, wren ng thornton wrote: > quoth Andrew Coppin: >> >> quoth Tristan Seligmann: >> > quoth Andrew Coppin: > > Sure, there are many concepts in Haskell which >> > just aren't found > > anywhere else. But monads? Catamorphisms? Coroutines? >> > Couldn't we > > think up some less intimidating terminology? > >> > The problem is that "less intimidating" terminology generally seems to >> > mean inaccurate or misleading terminology. >> >> I'm not sure I agree with that. >> >> Sure, simplifying things *can* make them less precise. But I don't believe >> it is always necessarily so. And I think we could try a little bit harder >> here. (Nothing too radical, just some small changes.) > > Consider the humble catamorphism (and anamorphism). Can you think of any > simple, descriptive, non-ambiguous name for this pattern other than the > technical name? An oft used name is "fold" (and "unfold") which is simple, > possibly descriptive, but certainly ambiguous. For example: the fold/unfold > names are used as jargon for optimization ---in compilers for logic > languages and query planning for databases--- for inlining functions and > then 'outlining' parts after doing some reorganization. There are other > technical uses which are just as different. > > The problem with simple terms for jargon is that they're all taken. When we > take everyday terms like "fold", "set", "list", "tree", "category", "type", > "kind", "sort", "variety", "domain", "group", et cetera and reappropriate > them for technical use there are two problems. The first is that all of the > simple everyday terms have already been appropriated time and again, so > using it will often be ambiguous. The second is that the technical meaning > often does not expressly match the daily meaning, which in turn means that > these terms will often be confusing or used casually in a way that confuses > the daily and technical meanings. > > It's all well and good for terminology to be non-intimidating, but for > technical terminology I think there must be a high premium on correctness as > well. Reappropriating terms which have fallen into disuse for their original > meanings (e.g. monad) or which are taken or invented from languages the > audience is unlikely to be familiar with (e.g. catamorphism) ensures that we > don't have to worry about baggage associated with those words. This is good > because it means there won't be conflicts of meaning, but it's bad because > it means the audience can't intuit an approximate meaning. Pedantic as I am > wont to be, I think the benefit outweighs the detriment, but YMMV. > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lennart at augustsson.net Fri Dec 19 04:16:23 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri Dec 19 04:08:55 2008 Subject: [Haskell-cafe] lengthOP rewrite rules In-Reply-To: <494B0F1F.7070603@freegeek.org> References: <1ff5dedc0812172339ga835a24ha813c1132bf2efc4@mail.gmail.com> <7ca3f0160812180002sd0eafe9y141e2ead4a7fe7f0@mail.gmail.com> <494B0F1F.7070603@freegeek.org> Message-ID: There is nothing "better" about terminating more often. Either your transformation has the same semantics as the original, in which case it is correct. Or your transformation has different sematics than the original, in which case it's incorrect. -- Lennart On Fri, Dec 19, 2008 at 3:03 AM, wren ng thornton wrote: > Luke Palmer wrote: >> >> This does not answer your question, but you can solve this problem without >> rewrite rules by having length return a lazy natural: >> >> data Nat = Zero | Succ Nat >> >> And defining lazy comparison operators on it. > > And if you want to go that route, then see Data.List.Extras.LazyLength from > list-extras[1]. Peano integers are quite inefficient, but this library does > the same transform efficiently. > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/list-extras > > >> Of course you cannot replace usages of Prelude.length. But I am really >> not >> in favor of rules which change semantics, even if they only make things >> less >> strict. My argument is the following. I may come to rely on such >> nonstrictness as in: >> >> bad xs = (length xs > 10, length xs > 20) >> >> bad [1..] will return (True,True). However, if I do an obviously >> semantics-preserving refactor: >> >> bad xs = (l > 10, l > 20) >> where >> l = length xs >> >> My semantics are not preserved: bad [1..] = (_|_, _|_) (if/unless the >> compiler is clever, in which case my semantics depend on the compiler's >> cleverness which is even worse) > > Data.List.Extras.LazyLength does have rewrite rules to apply the lazy > versions in place of Prelude.length where it can. My justification is > two-fold. First is that for finite lists the semantics are identical but the > memory behavior is strictly better. Second is that for non-finite lists the > termination behavior is strictly better. > > It's true that refactoring can disable either point, and that can alter > semantics in the latter case. Since the module is explicit about having > these rules, I would say that users should remain aware of the fact that > they're taking advantage of them or they should use the explicit lengthBound > or lengthCompare functions instead. > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From hakim.cassimally at gmail.com Fri Dec 19 04:34:17 2008 From: hakim.cassimally at gmail.com (Hakim Cassimally) Date: Fri Dec 19 04:26:52 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: Message-ID: <82cfa8030812190134k7c4beeafs89b8993c407bc02f@mail.gmail.com> (pesky non-reply-to-munged lists... here goes again, sorry Ashley for the duplicate :-) On 19/12/2008, Ashley Yakeley wrote: > I browsed around a bit for logos from other languages... > Perl > http://upload.wikimedia.org/wikipedia/en/e/e0/Programming-republic-of-perl.png > I'm not sure if this is "the Perl logo" or "O'Reilly's Perl logo", but it's > ugly, busy, difficult to read and a bit obscure. The title "PROGRAMMING > REPUBLIC OF" also lends an air of snotty pretension. D. Use of a camel image wrt Perl is trademarked O'Reilly. They usually use a plain camel image, the "Programming Republic of" is *a* fairly common logo, but by no means *the* official logo. Recently the Perl Foundation and others are promoting an onion logo (referencing Larry Wall's yearly "State of the Onion" talks, which is unencumbered by corporate trademarks: http://www.perl.org/simages/onion/onion-160x160a.gif -- osfameron From marlowsd at gmail.com Fri Dec 19 04:43:38 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Dec 19 04:36:14 2008 Subject: [Haskell-cafe] Re: Thread scheduling and GHC.Conc In-Reply-To: <1229634484.6299.18.camel@jrf-d620> References: <1229634484.6299.18.camel@jrf-d620> Message-ID: <494B6CCA.5050704@gmail.com> Jake Foell wrote: > using ghc v6.8.2 > Problem: > I am creating a program that forks two other lightweight threads. One > of the forked threads seems to be stuck or dead after running > successfully for a non-trivial amount of time. I am receiving no > error messages. > Questions: > What is the best way to diagnose this problem? (perhaps a ghc upgrade to > a version that includes processStatus?) > Does the runtime system ensure that no thread will starve for processor > time? > > My initial diagnosis: > by looking at log files that this program produces, it seems that the > thread in question is failing while receiving a response from a server. > Here is a simplified exerpt: > h <- connectTo server port > appendFile file "Connection Established\n" > hPutStr h httpRequestString > hFlush h > reply <- hGetContents h > appendFile file reply > If I look at the tail of file that is created, I see something similar > to this: > ... > Connection Established > here is the response... > Connection Established > Answers to my questions and/or any advice would be appreciated. thanks You might be able to find your problem by compiling the program with -debug and running it with +RTS -Ds. This produces debugging output from the scheduler - it's intended mainly for debugging the RTS and has a lot of info that won't make much sense to you, but it might help you find the problem. If you're curious about what the RTS is doing, there are a host of other -D debugging options available when you compile with -debug, use +RTS -? to list them. Cheers, Simon From tom.davie at gmail.com Fri Dec 19 04:45:10 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Dec 19 04:37:43 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <494AF347.9010809@cs.nott.ac.uk> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> Message-ID: <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> Hi Henrik, On 19 Dec 2008, at 02:05, Henrik Nilsson wrote: > Hi Tom, > > > I'm not sure why mapping the function is not satisfactory -- It > would > > create a new Behavior, who's internals contain only the two elements > > from the list -- that would expose to the garbage collector that the > > second element has no reference from this behavior any more, and > thus > > the whole behavior could be collected. > > We must be talking at cross purposes here: there is no way that > deleting the *output* from one of the behaviours from a list > of outputs would cause the underlying behavior whose output no longer > is observed to be garbage collected. After all, that list of > three numbers is just a normal value: why should removing one of > its elements, so to speak, affect the producer of the list? > > But if we have a list of running behaviors or signals, and that list > is changed, then yes, of course we get the desired behavior (this > is what Yampa does). > > So maybe that's what you mean? I'm afraid not, rereading what I said, I really didn't explain what I was talking about well. A Behavior in reactive is not just a continuous function of time. It is a series of steps, each of which carries a function of time. One such behavior might look like this: (+5) -> 5 , (+6) -> 10 , integral That is to say, this behavior starts off being a function that adds 5 to the current time. At 5 seconds, it steps, and the value changes to a function that adds 6 to time. At this point, the function that adds 5 to time can be garbage collected, along with the step. At 10 seconds, it becomes the integral of time, and the (+6) function, along with the next step is GCed. To come back to your example, I'd expect the behavior to look like this (using named functions only so that I can refer to them): i1 t = integral t i2 t = integral (2 * t) i3 t = integral (3 * t) f t = [i1 t, i2 t, i3 t)] g t = [i1 t, i3 t] f -> 2, g After 2 seconds, both f, and the first step may be garbage collected. As g does not have any reference to i2 t, it too can be garbage collected. I hope that answers you more clearly. > > That's a yes. My first answer to how to implement the resetting > > counter would be someting along the lines of this, but I'm not > certain > it's dead right: > > > > e = (1+) <$ mouseClick > > e' = (const 0) <$ > > b = accumB 0 (e `mappend` e') > > > > i.e. b is the behavior got by adding 1 every time the mouse click > > event occurs, but resetting to 0 whenever occurs. > > Hmm. Looks somewhat complicated to me. > > Anyway, it doesn't really answer the fundamental question: how > does one start a behavior/signal function at a particular point in > time? In reactive, one doesn't. All behaviors and events have the same absolute 0 value for time. One can however simulate such a behavior, by using a `switcher`, or accumB. In practice, having potentially large numbers of behaviors running but not changing until a certain event is hit is not a major problem. This is not a problem because reactive knows that the current step contains a constant value, not a "real" function of time, because of this, no changes are pushed, and no work is done, until the event hits. I believe Conal is however working on semantics for relative time based behaviors/events though. Thanks Tom Davie From marlowsd at gmail.com Fri Dec 19 04:48:33 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Dec 19 04:41:07 2008 Subject: [Haskell-cafe] Re: [reactive] problem with unamb -- doesn't kill enough threads In-Reply-To: References: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> Message-ID: <494B6DF1.20704@gmail.com> Sounds like you should use an exception handler so that when the parent dies it also kills its children. Be very careful with race conditions ;-) For a good example of how to do this sort of thing, see http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Timeout.html the docs are sadly missing the source links at the moment, I'm not sure why, but you can find the source in http://darcs.haskell.org/packages/base/System/Timeout.hs Cheers, Simon Conal Elliott wrote: > (I'm broadening the discussion to include haskell-cafe.) > > Andy -- What do you mean by "handling all thread forking locally"? > > - Conal > > On Thu, Dec 18, 2008 at 1:57 PM, Andy Gill > wrote: > > Conal, et. al, > > I was looking for exactly this about 6~9 months ago. I got the > suggestion to pose it as a challenge > to the community by Duncan Coutts. What you need is thread groups, > where for a ThreadId, you can send a signal > to all its children, even missing generations if needed. > > I know of no way to fix this at the Haskell level without handling > all thread forking locally. > > Perhaps a ICFP paper about the pending implementation :-) but I'm > not sure about the research content here. > > Again, there is something deep about values with lifetimes. > > Andy Gill > > > On Dec 18, 2008, at 3:43 PM, Conal Elliott wrote: > >> I realized in the shower this morning that there's a serious flaw >> in my unamb implementation as described in >> http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice. >> I'm looking for ideas for fixing the flaw. Here's the code for >> racing computations: >> >> race :: IO a -> IO a -> IO a >> a `race` b = do v <- newEmptyMVar >> ta <- forkPut a v >> tb <- forkPut b v >> x <- takeMVar v >> killThread ta >> killThread tb >> return x >> >> forkPut :: IO a -> MVar a -> IO ThreadId >> forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler >> `catch` bhandler) >> where >> uhandler (ErrorCall "Prelude.undefined") = return () >> uhandler err = throw err >> bhandler BlockedOnDeadMVar = return () >> >> The problem is that each of the threads ta and tb may have spawned >> other threads, directly or indirectly. When I kill them, they >> don't get a chance to kill their sub-threads. >> >> Perhaps I want some form of garbage collection of threads, perhaps >> akin to Henry Baker's paper "The Incremental Garbage Collection of >> Processes". As with memory GC, dropping one consumer would >> sometimes result is cascading de-allocations. That cascade is >> missing from my implementation. >> >> Or maybe there's a simple and dependable manual solution, >> enhancing the method above. >> >> Any ideas? >> >> - Conal >> >> >> _______________________________________________ >> Reactive mailing list >> Reactive@haskell.org >> http://www.haskell.org/mailman/listinfo/reactive > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From tanimoto at arizona.edu Fri Dec 19 05:43:18 2008 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Fri Dec 19 05:35:51 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: Message-ID: Hi Ashley, On Fri, Dec 19, 2008 at 2:10 AM, Ashley Yakeley wrote: > All of these get one thing right that the current and most of the proposed > Haskell logos do not: they don't make any reference to the syntax of the > language itself. Doing so seems to miss the point of a logo: it's supposed > to appeal visually, rather than semantically. So I'd like to see some > submissions that don't use lambdas. I wholeheartedly agree with you, despite being guilty of charge myself . : ) Part of the difficulty for us is that much of Haskell's beauty comes from abstraction, and the notation was created precisely to capture that, right? Before I go into some ideas, let me point to some logos that I find very cool: http://www.lisperati.com/logo.html Perhaps we could contact Conrad for help. Some ideas: * a hammock, symbolizing laziness * a banana, borrowing from the popular paper. I suppose lenses or barbed wire wouldn't be as catchy. * some blocks fitting together, a la tetris, representing the idea of strong typing * some plumbing, in the same vein as the previous one. I like to think of Haskell as a series of pipes fitting together, as opposed to a rube goldberg machine type of flowing. * an insect or animal: don't know which one, and I assume that beetle in the new book is trademarked by O'Reilly. Maybe something like FalconNL's Monica Monad, but a little more serious. * _|_: just as the joke, but this has the same problem as the lambda. I suspect it would be much easier if they had decided to stick with "Curry" as the language name. : ) Paulo PS: I'm CCing Conrad, I don't know if he's in this list. Here's the link so he knows what this is about: http://www.haskell.org/haskellwiki/Haskell_logos/New_logo_ideas From agocorona at gmail.com Fri Dec 19 06:05:55 2008 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Dec 19 05:58:28 2008 Subject: Fwd: Fwd: [Haskell-cafe] Haskell as a religion In-Reply-To: References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> <494AE7A3.3000306@henning-thielemann.de> <625b74080812181802w43916fe4o64ec1a41f8ee9db4@mail.gmail.com> Message-ID: ---------- Forwarded message ---------- From: Alberto G. Corona Date: 2008/12/19 Subject: Re: Fwd: [Haskell-cafe] Haskell as a religion To: Dan Piponi As far as I know, const only protect from updates that the compiler can detect at compilation time. Moreover, the C/C++ code does not make use of true referential transparency properties, for example const a=1; const b=a perform a copy of content of a to b . In haskell a=1; b=a make b to point to a directly. 2008/12/19 Dan Piponi On Thu, Dec 18, 2008 at 4:15 PM, Henning Thielemann > wrote: > > > In C/C++ referential transparent functions code can be declared by > > appending a 'const' to the prototype, right? > > For one thing, some fields in a const C++ object can be explicitly set > mutable. mutable is sometimes used in C++ a similar way to > unsafePerformIO in Haskell. You have something that uses mutability in > its internals but that mutability shouldn't be observable to the > caller. In both cases you have no means of actually ensuring that the > mutability is actually unobservable. > -- > Dan > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/aabb58e7/attachment.htm From jon.fairbairn at cl.cam.ac.uk Fri Dec 19 06:19:03 2008 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Fri Dec 19 06:11:46 2008 Subject: [Haskell-cafe] Re: Logos of Other Languages References: Message-ID: Ashley Yakeley writes: > All of these get one thing right that the current and most > of the proposed Haskell logos do not: they don't make any > reference to the syntax of the language itself. Doing so > seems to miss the point of a logo: it's supposed to appeal > visually, rather than semantically. So I'd like to see some > submissions that don't use lambdas. Perhaps something elaborating on the general lines of this: ? (Also .svg if anyone wants to develop it; that's a very quick sketch). It's simple, bold and forward looking ;-). It would need careful choice of colours: make the H blue and the Arrow red and it looks too British, make the H red and the arrow black, and it looks fascist (I suppose there are those who think that might be apposite). And it needs a much friendlier choice of typeface. That's a badge rather than a logo, but we certainly want one of those. Just add the "askell" part to get a logo? -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2008-04-26) From jules at jellybean.co.uk Fri Dec 19 06:38:13 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Dec 19 06:30:45 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: Message-ID: <494B87A5.9080908@jellybean.co.uk> Ashley Yakeley wrote: > All of these get one thing right that the current and most of the > proposed Haskell logos do not: they don't make any reference to the > syntax of the language itself. Doing so seems to miss the point of a > logo: it's supposed to appeal visually, rather than semantically. So I'd > like to see some submissions that don't use lambdas. [The following is my opinion, I don't intend to suggest it as objective fact] The first duty of a logo is to be memorable and distinctive, and work at a variety of sizes and colours (including black and white). The second duty is to be attractive. The third duty is to actually convey some kind of message about the thing the logo pertains to. The more famous you are as a brand, the more you can neglect the third point (you don't need to educate, people know what you are). So I agree with Ashley insofar as, there is no *need* for the logo to incorporate a lambda or a >> or suchlike devices. On the other hand, I think it's not necessarily a bad thing either, as long as it works with (1) and (2) above. Jules From info at tobias-kraentzer.de Fri Dec 19 07:53:59 2008 From: info at tobias-kraentzer.de (=?ISO-8859-1?Q?Tobias_Kr=E4ntzer?=) Date: Fri Dec 19 07:46:52 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: Message-ID: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> Am 19.12.2008 um 11:43 schrieb Paulo Tanimoto: > * an insect or animal: don't know which one, and I assume that beetle > in the new book is trademarked by O'Reilly. Maybe something like > FalconNL's Monica Monad, but a little more serious. Just as an idea: http://en.wikipedia.org/wiki/Sloth These animals are very lazy and very cool ;-) . . . Tobias From ketil at malde.org Fri Dec 19 08:00:29 2008 From: ketil at malde.org (Ketil Malde) Date: Fri Dec 19 07:53:02 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: <494B87A5.9080908@jellybean.co.uk> (Jules Bean's message of "Fri\, 19 Dec 2008 11\:38\:13 +0000") References: <494B87A5.9080908@jellybean.co.uk> Message-ID: <874p109v6a.fsf@malde.org> Jules Bean writes: > So I agree with Ashley insofar as, there is no *need* for the logo to > incorporate a lambda or a >> or suchlike devices. > On the other hand, I think it's not necessarily a bad thing either, as > long as it works with (1) and (2) above. I agree with this, but would also add that referring to foundations, history or theory (lambda) is better than referring to syntax (>>). I don't know if it was proposed as a serious option, but I quite like the idea of using _|_ as a symbol. -k -- If I haven't seen further, it is by standing in the footprints of giants From felipe.lessa at gmail.com Fri Dec 19 08:06:01 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Dec 19 07:58:31 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: <874p109v6a.fsf@malde.org> References: <494B87A5.9080908@jellybean.co.uk> <874p109v6a.fsf@malde.org> Message-ID: On Fri, Dec 19, 2008 at 11:00 AM, Ketil Malde wrote: > I agree with this, but would also add that referring to foundations, history or > theory (lambda) is better than referring to syntax (>>). I don't know > if it was proposed as a serious option, but I quite like the idea of using > _|_ as a symbol. At least here the symbol _|_ is commonly used to denote that offensive gesture that we don't want to see in a logo. Please don't do that =). (By "commonly" I mean "by everyone who doesn't know what 'bottom' is".) -- Felipe. From hpacheco at gmail.com Fri Dec 19 08:53:13 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Fri Dec 19 08:45:45 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> References: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> Message-ID: <7b92c2840812190553w3a5e7b22p5e848df3be5d2fd9@mail.gmail.com> I like the ideia, and could imagine something like this: http://i41.tinypic.com/se65ux.jpg Sorry for the bad drawing and scanning quality. If someone likes the ideia, I'm sure they can do much better than me :) hugo On Fri, Dec 19, 2008 at 12:53 PM, Tobias Kr?ntzer wrote: > > Am 19.12.2008 um 11:43 schrieb Paulo Tanimoto: > >> * an insect or animal: don't know which one, and I assume that beetle >> in the new book is trademarked by O'Reilly. Maybe something like >> FalconNL's Monica Monad, but a little more serious. >> > > > Just as an idea: http://en.wikipedia.org/wiki/Sloth > > These animals are very lazy and very cool ;-) > > . . . Tobias > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/4f0e5e06/attachment.htm From d at domob.eu Fri Dec 19 08:40:40 2008 From: d at domob.eu (Daniel Kraft) Date: Fri Dec 19 09:07:35 2008 Subject: [Haskell-cafe] sort and lazyness (?) Message-ID: Hi, I'm just a beginner trying to learn a little about Haskell, and as such write some toy programs (e.g. for projecteuler.net) in Haskell. Currently, I'm experiencing what I would call "strange behaviour": I've got a data-type data Fraction = Fraction Int Int to hold rational numbers (maybe there's already some built-in type for this in Haskell, much like for instance Scheme has a rational type?), and then I compute a list of pairs of those numbers, that is [(Fraction, Fraction)]. Fraction is declared an instance of Ord. This list has up to 3 million elements. If I do main = print $ length $ points then the program prints out the length fine and takes around 6s to finish (compiled with GHC -O3). Ok, but I acknowledge that length isn't quite an expensive function, as I can imagine that Haskell does not compute and hold the entire list for this but instead each element at once and discards it afterwards. Doing main = print $ length $ map (\(x, _) -> x == Fraction 1 2) points instead, gives a slightly longer runtime (6.6s), but in this case I'm sure that at least each element is computed; right? main = print $ length $ reverse points gives 11.9s, and here I guess (?) that for this to work, the entire list is computed and hold in memory. However, trying to do import List main = print $ length $ sort points makes memory usage go up and the program does not finish in 15m, also spending most time waiting for swapped out memory. What am I doing wrong, why is sort this expensive in this case? I would assume that computing and holding the whole list does not take too much memory, given its size and data type; doing the very same calculation in C should be straight forward. And sort should be O(n * log n) for time and also not much more expensive in memory, right? Am I running into a problem with lazyness? What can I do to avoid it? As far as I see it though, the reverse or map call above should do nearly the same as sort, except maybe that the list needs to be stored in memory as a whole and sort has an additional *log n factor, but neither of those should matter. What's the problem here? Is this something known with sort or similar functions? I couldn't find anything useful on Google, though. My code is below, and while I would of course welcome critics, I do not want to persuade anyone to read through it. Thanks a lot, Daniel ---------------------------------------------------------- -- Problem 165: Intersections of lines. import List -- The random number generator. seeds :: [Integer] seeds = 290797 : [ mod (x * x) 50515093 | x <- seeds ] numbers :: [Int] numbers = map fromInteger (map (\x -> mod x 500) (tail seeds)) -- Line segments, vectors and fractions. data Segment = Segment Int Int Int Int data Vector = Vector Int Int data Fraction = Fraction Int Int instance Eq Fraction where (Fraction a b) == (Fraction c d) = (a == c && b == d) instance Ord Fraction where compare (Fraction a b) (Fraction c d) | (a == c && b == d) = EQ | b > 0 = if a * d < b * c then LT else GT | otherwise = if a * d > b * c then LT else GT -- Build a normalized fraction and get its value. normalize (Fraction a b) = let g = gcd a b; aa = div a g; bb = div b g in if bb < 0 then Fraction (-aa) (-bb) else Fraction aa bb -- Find the inner product of two vectors. innerProduct (Vector a b) (Vector c d) = a * c + b * d -- Find the normal vector and direction of a line segment, as well as -- the constant in straight-normal form for a given normal vector. normalVector (Segment x1 y1 x2 y2) = Vector (y1 - y2) (x2 - x1) direction (Segment x1 y1 x2 y2) = Vector (x2 - x1) (y2 - y1) nfConstant (Segment x1 y1 x2 y2) n = innerProduct n (Vector x1 y1) -- Check if a point is between the ends of the segment times D. betweenEndsTimes d (Segment x1 y1 x2 y2) xD yD = let x1D = x1 * d; x2D = x2 * d; y1D = y1 * d; y2D = y2 * d; xDMin = min x1D x2D; xDMax = max x1D x2D; yDMin = min y1D y2D; yDMax = max y1D y2D in (xDMin <= xD && xDMax >= xD && yDMin <= yD && yDMax >= yD && (x1D /= xD || y1D /= yD) && (x2D /= xD || y2D /= yD)) -- If they are not parallel, we can find their intersection point (at least, -- the one it would be if both were straights). Then it is easy to check if -- it is between the endpoints for both. -- -- n1 * x + m1 * y = c1 -- n2 * x + m2 * y = c2 -- -- => x = (c1 * m2 - x2 * m1) / (n1 * m2 - n2 * m1) -- => y = (n1 * c2 - n2 * c1) / (n1 * m2 - n2 * m1) -- -- (Iff they are parallel, the determinant will be 0.) trueIntersect s1 s2 = let (Vector n1 m1) = normalVector s1; (Vector n2 m2) = normalVector s2; c1 = nfConstant s1 (Vector n1 m1); c2 = nfConstant s2 (Vector n2 m2); d = n1 * m2 - n2 * m1; xD = c1 * m2 - c2 * m1; yD = n1 * c2 - n2 * c1 in if d == 0 then Nothing else if (betweenEndsTimes d s1 xD yD) && (betweenEndsTimes d s2 xD yD) then Just ((normalize $ Fraction xD d), (normalize $ Fraction yD d)) else Nothing -- Build list of segments. takeEveryForth :: [Int] -> [Int] takeEveryForth (a:_:_:_:t) = a : (takeEveryForth t) n1 = numbers n2 = tail n1 n3 = tail n2 n4 = tail n3 segments = [ Segment a b c d | ((a, b), (c, d)) <- zip (zip (takeEveryForth n1) (takeEveryForth n2)) (zip (takeEveryForth n3) (takeEveryForth n4)) ] -- For the first 5000 segments, calculate intersections. firstSegments = take 5000 segments intersects :: [Maybe (Fraction, Fraction)] intersects = findInters firstSegments [] where findInters [] l = l findInters (h:t) l = findInters t (addInters h t l) where addInters _ [] l = l addInters e (h:t) l = addInters e t ((trueIntersect e h) : l) getPoints :: [Maybe (Fraction, Fraction)] -> [(Fraction, Fraction)] getPoints [] = [] getPoints (Nothing : t) = getPoints t getPoints ((Just v) : t) = v : (getPoints t) points = getPoints intersects -- Main program. main :: IO () main = print $ length $ reverse points --main = print $ length $ map (\(x, _) -> x == Fraction 1 2) points --main = print $ length $ sort points From ninegua at gmail.com Fri Dec 19 09:31:27 2008 From: ninegua at gmail.com (Paul L) Date: Fri Dec 19 09:24:25 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> Message-ID: <856033f20812190631x70854644t421f56c1c7f05872@mail.gmail.com> Nice to see this discussion, and I just want to comment on the applicative v.s. arrow style. The example Henrik gave is z <- sf2 <<< sf1 -< x which models a composition, and is in general the strength of a combinator approach. But the strength of Applicative, in my opinion, is not composition but currying: f <*> x <*> y where f can have the type Behavior a -> Behavior b -> Behavior c. I don't think there is an exact match in arrows. One could, however, require sf to be of type SF (a, b) c, and write z <- sf -< (x, y) The tupling may seem an extra burden, but it's an inherent design choice of arrows, which builds data structure on top of products, and people can't run away from it when writing arrow programs. -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From jake at pikewerks.com Fri Dec 19 09:37:29 2008 From: jake at pikewerks.com (Jake Mcarthur) Date: Fri Dec 19 09:30:02 2008 Subject: [Haskell-cafe] sort and lazyness (?) In-Reply-To: References: Message-ID: <98E522BA-C1F2-4E2B-A070-B0BD1DBAA216@pikewerks.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Dec 19, 2008, at 7:40 AM, Daniel Kraft wrote: > data Fraction = Fraction Int Int > > to hold rational numbers (maybe there's already some built-in type > for this in Haskell, much like for instance Scheme has a rational > type?), There is one. It is called Rational. :) > and then I compute a list of pairs of those numbers, that is > [(Fraction, Fraction)]. Fraction is declared an instance of Ord. > > This list has up to 3 million elements. If I do > > main = print $ length $ points > > then the program prints out the length fine and takes around 6s to > finish (compiled with GHC -O3). Ok, but I acknowledge that length > isn't quite an expensive function, as I can imagine that Haskell > does not compute and hold the entire list for this but instead each > element at once and discards it afterwards. Unless something has changed since I last checked, there is little difference between ghc -O2 and ghc -O3, and the latter can even be slower much of the time. It may depend on the situation, but I'm just letting you know. In this case, the runtime should not actually be computing _any_ of the elements of the list since it doesn't care what their values are. You are only counting them, not using them, so it really only computes the spine of the list. > Doing > > main = print $ length $ map (\(x, _) -> x == Fraction 1 2) points > > instead, gives a slightly longer runtime (6.6s), but in this case > I'm sure that at least each element is computed; right? No. The elements' values are still not actually used, so you are still only evaluating the spine of the list. > main = print $ length $ reverse points > > gives 11.9s, and here I guess (?) that for this to work, the entire > list is computed and hold in memory. This is beginning to sound like you think Haskell lists are arrays. They aren't. They are actually linked lists. In order to reverse a linked list, you have to travel all the way to the end and then reconstruct it from there. This explains the time increase. It doesn't really have anything to do with computing the elements or holding anything in memory. > However, trying to do > > import List > main = print $ length $ sort points > > makes memory usage go up and the program does not finish in 15m, > also spending most time waiting for swapped out memory. What am I > doing wrong, why is sort this expensive in this case? I would > assume that computing and holding the whole list does not take too > much memory, given its size and data type; doing the very same > calculation in C should be straight forward. And sort should be O(n > * log n) for time and also not much more expensive in memory, right? This is actually the first time you really evaluated any of the elements of the list, hence a massive increase in memory use. - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAklLsaoACgkQye5hVyvIUKlJYgCfYtwPv/neOnl3+wIu8VhIqfoA lXMAn3EmANZbSRyYeOiXtOdGl7hxCj34 =NJwT -----END PGP SIGNATURE----- From Alistair.Bayley at invesco.com Fri Dec 19 09:41:49 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Dec 19 09:34:23 2008 Subject: [Haskell-cafe] sort and lazyness (?) In-Reply-To: References: Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> > Currently, I'm experiencing what I would call "strange behaviour": > > I've got a data-type > > data Fraction = Fraction Int Int > > to hold rational numbers (maybe there's already some built-in > type for this in Haskell, http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Ratio.html > This list has up to 3 million elements. If I do > > main = print $ length $ points > > main = print $ length $ map (\(x, _) -> x == Fraction 1 2) points > > main = print $ length $ reverse points > > However, trying to do > > import List > main = print $ length $ sort points > > makes memory usage go up and the program does not finish in 15m, also > spending most time waiting for swapped out memory. What am I doing > wrong, why is sort this expensive in this case? I would assume that > computing and holding the whole list does not take too much memory, > given its size and data type; doing the very same calculation in C > should be straight forward. And sort should be O(n * log n) for time > and also not much more expensive in memory, right? Not having looked at your code, I think you are benefiting from fusion/deforestation in the first three main functions. In this case, although you may appear to be evaluating the entire list, in fact the list elements can be discarded as they are generated, so functions like length and reverse can run using constant space, rather than O(n) space. The sort function, however, requires that the entire list is retained, hence greater memory usage. I also think you are optimistic in the memory requirements of your 3 million element list. A list of Ints will take a lot more than 4 bytes per element (on 32-bit machines) because there's overhead for the list pointers, plus possibly the boxes for the Ints themselves. I think there are 3 machine words for each list entry (pointer to this element, pointer to next element, info-table pointer), and 2 words for each Int, but I'm just guessing: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObje cts You might get some mileage by suggesting to GHC that your Fraction type is strict e.g. > data Fraction = Fraction !Int !Int which might persuade it to unbox the Ints, giving some space savings. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From briqueabraque at yahoo.com Fri Dec 19 09:49:37 2008 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Fri Dec 19 09:42:16 2008 Subject: [Haskell-cafe] Re: Detecting system endianness In-Reply-To: <494B168C.8020900@freegeek.org> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> <200812181403.40459.holgersiegel74@yahoo.de> <494B168C.8020900@freegeek.org> Message-ID: But why would you want that? I understand the only situation when talking about number of bytes makes sense is when you are using Foreign and Ptr. Besides that, you can only guess the amount of memory you need to deal with your data (taking laziness, GC etc. into account). Maur?cio > In a similar vein, is there already a function available to give the > size of Word in bytes? Or should I write the usual Ptr conversion tricks > to figure it out? > > > > Holger Siegel wrote: >> On Thursday 18 December 2008 13:40:47 Ryan Ingram wrote: >>> Actually, this is probably safer: >>> >>> import Foreign.Marshal.Alloc >>> import Foreign.Ptr >>> import Foreign.Storable >>> import Data.Word >>> import System.IO.Unsafe From duncan.coutts at worc.ox.ac.uk Fri Dec 19 09:53:23 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Dec 19 09:45:54 2008 Subject: [Haskell-cafe] sort and lazyness (?) In-Reply-To: References: Message-ID: <1229698403.10115.737.camel@localhost> On Fri, 2008-12-19 at 14:40 +0100, Daniel Kraft wrote: > Hi, > > I'm just a beginner trying to learn a little about Haskell, and as such > write some toy programs (e.g. for projecteuler.net) in Haskell. > > Currently, I'm experiencing what I would call "strange behaviour": > > I've got a data-type > > data Fraction = Fraction Int Int > > to hold rational numbers (maybe there's already some built-in type for > this in Haskell, much like for instance Scheme has a rational type?), > and then I compute a list of pairs of those numbers, that is > [(Fraction, Fraction)]. Fraction is declared an instance of Ord. > > This list has up to 3 million elements. If I do > > main = print $ length $ points > > then the program prints out the length fine and takes around 6s to > finish (compiled with GHC -O3). Ok, but I acknowledge that length isn't > quite an expensive function, as I can imagine that Haskell does not > compute and hold the entire list for this but instead each element at > once and discards it afterwards. Right. > Doing > > main = print $ length $ map (\(x, _) -> x == Fraction 1 2) points > > instead, gives a slightly longer runtime (6.6s), but in this case I'm > sure that at least each element is computed; right? Nope. Nothing looks at the result of the comparison so it is not done and so it does not force any of the fractions to be computed. > main = print $ length $ reverse points > > gives 11.9s, and here I guess (?) that for this to work, the entire list > is computed and hold in memory. Yes, the list is held in memory but the elements are not computed. > However, trying to do > > import List > main = print $ length $ sort points Now it really does have to compute the elements because comparing the elements involves inspecting them. > makes memory usage go up and the program does not finish in 15m, also > spending most time waiting for swapped out memory. Right. Much more memory used this time and that is pushing your machine into swapping which then goes very very slowly. > What am I doing wrong, why is sort this expensive in this case? Sort itself is not so expensive, the expensive thing was calculating all the elements of your list and sort was the first function that had to do it. If you used something like sum (rather than length) then it'd hit the same issue as it would need to evaluate each element. > I would assume that computing and holding the whole list does not take > too much memory, given its size and data type; That does not seem to be the case. data Fraction = Fraction Int Int This takes 7 words per Fraction. There's 3 words for the Fraction constructor and it's two fields. Each Int also takes 2 words. On a 32bit machine that is 28 bytes, or 56 on a 64bit machine. We can reduce the memory requirements for Fraction by making the Int's strict and unpacking them into the Fraction constructor: data Fraction = Fraction {-# UNPACK #-} !Int {-# UNPACK #-} !Int Now it takes 3 words per Fraction. However it is no longer so lazy. Previously you could have (Fraction 3 (error "not used")) and as long as you never looked at the second Int it would work. Now that we made both fields strict (the ! on the fields) that does not work any more, (Fraction 3 (error "not used")) will produce the error, even if we only look at the first Int. > doing the very same calculation in C should be straight forward. In an eager language like C the first one would have failed too because it would have had to compute all the elements eagerly and holding them all in memory at once seems to require more memory than your machine has. On the other hand C would use something more like the strict variant I mentioned above so the initial memory requirements would probably be lower. > And sort should be O(n * log n) for time and also not much more > expensive in memory, right? Sort does take a bit more memory than just reversing because it has to construct some intermediate lists while merging. > Am I running into a problem with lazyness? A problem in your understanding of lazyness. > What can I do to avoid it? Look at this again: length $ map (\(x, _) -> x == Fraction 1 2) points Try something like: length $ map (\_ -> error "look! never evaluated!") points you'll find it gives the same answer. That's because length never looks at the elements of the list. > As far as I see it though, the reverse or map call above should do > nearly the same as sort, except maybe that the list needs to be stored > in memory as a whole and sort has an additional *log n factor, but > neither of those should matter. What's the problem here? reverse never looks at the elements of the list, sort does. Duncan From Alistair.Bayley at invesco.com Fri Dec 19 09:53:27 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Dec 19 09:46:07 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> References: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E97D0@GBLONXMB02.corp.amvescap.net> > Am 19.12.2008 um 11:43 schrieb Paulo Tanimoto: > > * an insect or animal: don't know which one, and I assume > that beetle > > in the new book is trademarked by O'Reilly. Maybe something like > > FalconNL's Monica Monad, but a little more serious. > > > Just as an idea: http://en.wikipedia.org/wiki/Sloth > > These animals are very lazy and very cool ;-) Can you trademark a picture of a beetle? I would think that, if the book becomes sufficiently popular, that the beetle will become the associated animal (is that how Perl's camel became its icon?). I'd like to know what the relationship is between the O'Reilly camel and the Perl camel - was the Perl Foundation or perl.org given permission to use the camel? That said, I also like the sloth. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From d at domob.eu Fri Dec 19 09:58:52 2008 From: d at domob.eu (Daniel Kraft) Date: Fri Dec 19 09:47:54 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> Message-ID: Bayley, Alistair wrote: >> Currently, I'm experiencing what I would call "strange behaviour": >> >> I've got a data-type >> >> data Fraction = Fraction Int Int >> >> to hold rational numbers (maybe there's already some built-in >> type for this in Haskell, > > http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Ratio.html Thanks for the pointer, I knew there would be something already there :) >> This list has up to 3 million elements. If I do >> >> main = print $ length $ points >> >> main = print $ length $ map (\(x, _) -> x == Fraction 1 2) points >> >> main = print $ length $ reverse points >> >> However, trying to do >> >> import List >> main = print $ length $ sort points >> >> makes memory usage go up and the program does not finish in 15m, also >> spending most time waiting for swapped out memory. What am I doing >> wrong, why is sort this expensive in this case? I would assume that >> computing and holding the whole list does not take too much memory, >> given its size and data type; doing the very same calculation in C >> should be straight forward. And sort should be O(n * log n) for time >> and also not much more expensive in memory, right? > > Not having looked at your code, I think you are benefiting from > fusion/deforestation in the first three main functions. In this case, > although you may appear to be evaluating the entire list, in fact the > list elements can be discarded as they are generated, so functions like > length and reverse can run using constant space, rather than O(n) space. How does reverse work in constant space? At the moment I can't imagine it doing so; that's why I tried it, but of course you could be right. > The sort function, however, requires that the entire list is retained, > hence greater memory usage. I also think you are optimistic in the > memory requirements of your 3 million element list. A list of Ints will > take a lot more than 4 bytes per element (on 32-bit machines) because > there's overhead for the list pointers, plus possibly the boxes for the > Ints themselves. I think there are 3 machine words for each list entry > (pointer to this element, pointer to next element, info-table pointer), > and 2 words for each Int, but I'm just guessing: > http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObje > cts Of course that's the case, but the list being 3 million elements, and not, say 100 (which would still fit into memory for a simple C array of ints) I thought would make it possible. Otherwise, how can one handle such amounts in data anyway? Only using arrays? > You might get some mileage by suggesting to GHC that your Fraction type > is strict e.g. > >> data Fraction = Fraction !Int !Int > > which might persuade it to unbox the Ints, giving some space savings. I already tried so, but this doesn't change anything to the performance. I will however try now to use the provided rational type, maybe this helps. Thanks for the answers, Daniel From lutz at iks-jena.de Fri Dec 19 10:05:40 2008 From: lutz at iks-jena.de (Lutz Donnerhacke) Date: Fri Dec 19 09:58:13 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) References: Message-ID: * Daniel Kraft wrote: > Otherwise, how can one handle such amounts in data anyway? > Only using arrays? Data.Array or some problem specific data structure. From golubovsky at gmail.com Fri Dec 19 10:06:02 2008 From: golubovsky at gmail.com (Dimitry Golubovsky) Date: Fri Dec 19 09:58:34 2008 Subject: [Haskell-cafe] Automatic instance constraints derivation: how? Message-ID: Hi, I am trying to understand, why do I need to place constraints with class instance declaration while all the information seems to be already available to the compiler. I have placed the code in question here: http://codepad.org/Akew0p2t so anybody can play with it. The code tries to model evaluation of GRIN-style thunks using Haskell type classes instead of tag-based pattern matching, as in the GRIN papers. That is, a thunk is represented as a datatype like data Ffun a b c = Ffun a b c, and there is some "eval" function which being applied to such data results in the call fun a b c. Such "eval" function is a method of class Eval: class Eval a b | a -> b where eval :: (Monad m) => a -> m b which means that thunks of some type (a) evaluate to values of some dependent type (b). The code is monadic because GRIN is a monad, so the code looks similar to GRIN. The ultimate goal is to make GRIN code understandable by Haskell compiler. Everything is fine with "simple" types like Int, that is "instance Eval Int Int" means that Int (and Char, and Bool) do not need in fact evaluation at all. instance Eval Int Int where eval = return Everything is fine with thunks encoding calls to primitives. See instances for FADD and FSUB. All type information for primitives (primPlusInt, primMinusInt) is specified in the code. Then, a function "fun" is defined that calls the primitives. The "main" function illustrates its use, and everything works as expected, as output shows. But when I tried to define a thunk for "fun" (instance for Ffun) I was only able to do that with all constraints on its parameters explicitly set. OTOH, even if I comment out the instance Eval for Ffun, and load the code in Hugs (or GHCi, doesn't matter) then type signature of "fun" is correctly derived by the compiler. If I try to define instance for Ffun like this: instance (Eval x x) => Eval (Ffun a b c) x where eval (Ffun a b c) = fun a b c meaning only the fact that result of the function "fun" will be like Int or Bool - evaluates to itself, and we don't care about the types of arguments, I cannot use forall x. with instance declaration, so I have to say something about x. I get the error (Hugs): Error occurred ERROR line 51 - Instance is more general than a dependency allows *** Instance : Eval (Ffun a b c) d *** For class : Eval a b *** Under dependency : a -> b So, is there a way to define such an instance for a thunk without any constraints? Wouldn't it be reasonable to expect that eval (Ffun a b c) = fun a b c would allow the compiler to retrieve constraints on a, b, c from those already known for the called function? Thanks. -- Dimitry Golubovsky Anywhere on the Web From lrpalmer at gmail.com Fri Dec 19 10:12:02 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Dec 19 10:04:33 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> Message-ID: <7ca3f0160812190712k1f7e7427occ5a03171c8c0c77@mail.gmail.com> On Fri, Dec 19, 2008 at 7:58 AM, Daniel Kraft wrote: > > Not having looked at your code, I think you are benefiting from >> fusion/deforestation in the first three main functions. In this case, >> although you may appear to be evaluating the entire list, in fact the >> list elements can be discarded as they are generated, so functions like >> length and reverse can run using constant space, rather than O(n) space. >> > > How does reverse work in constant space? At the moment I can't imagine it > doing so; that's why I tried it, but of course you could be right. No, you are correct, reverse is not constant space. However, as Duncan explained, reverse does not force any elements of the list, so even if you had a list of elements which consumed 1Mb each (when fully evaluated), they would not be forced so the memory would look exactly the same. > > The sort function, however, requires that the entire list is retained, >> hence greater memory usage. I also think you are optimistic in the >> memory requirements of your 3 million element list. A list of Ints will >> take a lot more than 4 bytes per element (on 32-bit machines) because >> there's overhead for the list pointers, plus possibly the boxes for the >> Ints themselves. I think there are 3 machine words for each list entry >> (pointer to this element, pointer to next element, info-table pointer), >> and 2 words for each Int, but I'm just guessing: >> http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObje >> cts >> > > Of course that's the case, but the list being 3 million elements, and not, > say 100 (which would still fit into memory for a simple C array of ints) I > thought would make it possible. Otherwise, how can one handle such amounts > in data anyway? Only using arrays? Well, if you know the size beforehand and you know the whole thing needs to fit into memory at the same time, an array is usually a better choice than a list. Lists are more like loops -- i.e. control flow rather than data, whereas Arrays are definitely data. I realize the imprecision of that statement... However, I am not sure what all this jabber about swapping is. 28 bytes/elt * 3,000,000 elts = 84 Mb, which easily fits into a modern machine's memory. There are a lot of traps for the unwary in memory performance though. Depending on how things are defined, you may be computing *too* lazily, building up thunks when you should just be crunching numbers. Still, swapping on this 3,000,000 element list is absurd, and we should look closer into your example. Post the rest (eg. the instances?)? Luke > > You might get some mileage by suggesting to GHC that your Fraction type >> is strict e.g. >> >> data Fraction = Fraction !Int !Int >>> >> >> which might persuade it to unbox the Ints, giving some space savings. >> > > I already tried so, but this doesn't change anything to the performance. I > will however try now to use the provided rational type, maybe this helps. > > Thanks for the answers, > Daniel > > > _______________________________________________ > 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/20081219/b2456f11/attachment.htm From duncan.coutts at worc.ox.ac.uk Fri Dec 19 10:26:19 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Dec 19 10:19:04 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> Message-ID: <1229700379.10115.747.camel@localhost> On Fri, 2008-12-19 at 15:58 +0100, Daniel Kraft wrote: > How does reverse work in constant space? At the moment I can't imagine > it doing so; that's why I tried it, but of course you could be right. It allocates a new list cell for every cell it finds in the input list. If the input list can be garbage collected then reverse takes constant space because each time it inspects a list cell from the input list that cell can be garbage collected. If the input list is being retained for some other reason then reverse will take linear space. > > You might get some mileage by suggesting to GHC that your Fraction type > > is strict e.g. > > > >> data Fraction = Fraction !Int !Int > > > > which might persuade it to unbox the Ints, giving some space savings. > > I already tried so, but this doesn't change anything to the performance. > I will however try now to use the provided rational type, maybe this > helps. It will not make any difference to the space used by Fraction unless you also unpack them as I mentioned in my other post. Duncan From lrpalmer at gmail.com Fri Dec 19 10:44:50 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Dec 19 10:37:21 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: <1229700379.10115.747.camel@localhost> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> <1229700379.10115.747.camel@localhost> Message-ID: <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> On Fri, Dec 19, 2008 at 8:26 AM, Duncan Coutts wrote: > On Fri, 2008-12-19 at 15:58 +0100, Daniel Kraft wrote: > > > How does reverse work in constant space? At the moment I can't imagine > > it doing so; that's why I tried it, but of course you could be right. > > It allocates a new list cell for every cell it finds in the input list. > If the input list can be garbage collected then reverse takes constant > space because each time it inspects a list cell from the input list that > cell can be garbage collected. If the input list is being retained for > some other reason then reverse will take linear space. I don't think that's true. It must inspect the whole input list to give the first element of the output list, but it cannot garbage collect the input list because it needs to yield every element of it. When I tested: ghci> length $ reverse [1..10^7] It certainly did not run in constant space. I think that if the first half of the output list is unused, then the second half of the input list will be collected (I'm having trouble visualizing the dynamics of this case though). But for the very first cons of the output, the whole input list (spine) needs to be in memory. Luke > > > > > You might get some mileage by suggesting to GHC that your Fraction type > > > is strict e.g. > > > > > >> data Fraction = Fraction !Int !Int > > > > > > which might persuade it to unbox the Ints, giving some space savings. > > > > I already tried so, but this doesn't change anything to the performance. > > I will however try now to use the provided rational type, maybe this > > helps. > > It will not make any difference to the space used by Fraction unless you > also unpack them as I mentioned in my other post. > > Duncan > > _______________________________________________ > 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/20081219/cfa80f62/attachment.htm From Alistair.Bayley at invesco.com Fri Dec 19 10:54:44 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Dec 19 10:47:18 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> <1229700379.10115.747.camel@localhost> <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025D69@GBLONXMB02.corp.amvescap.net> > > How does reverse work in constant space? At the > moment I can't imagine > > it doing so; that's why I tried it, but of course you > could be right. > > > It allocates a new list cell for every cell it finds in > the input list. > If the input list can be garbage collected then reverse > takes constant > space because each time it inspects a list cell from > the input list that > cell can be garbage collected. If the input list is > being retained for > some other reason then reverse will take linear space. > > > I don't think that's true. It must inspect the whole input > list to give the first element of the output list, but it > cannot garbage collect the input list because it needs to > yield every element of it. reverse creates the output list by pulling items from the head of the input list, and prefixing them to the output list. After each item has been pulled from the input, the list node can be GC'd from the input list. Also, if the output list is itself being consumed by a function which does not require the entire list (like length) then again the list node can be GC'd soon after consumption. > ghci> length $ reverse [1..10^7] This is a compiler optimisation, I think, so will probably require ghc -O(2?). Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From lrpalmer at gmail.com Fri Dec 19 11:14:44 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Dec 19 11:07:15 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025D69@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> <1229700379.10115.747.camel@localhost> <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA911025D69@GBLONXMB02.corp.amvescap.net> Message-ID: <7ca3f0160812190814r775c44cbp241563749489a033@mail.gmail.com> On Fri, Dec 19, 2008 at 8:54 AM, Bayley, Alistair < Alistair.Bayley@invesco.com> wrote: > > > How does reverse work in constant space? At the > > moment I can't imagine > > > it doing so; that's why I tried it, but of course you > > could be right. > > > > > > It allocates a new list cell for every cell it finds in > > the input list. > > If the input list can be garbage collected then reverse > > takes constant > > space because each time it inspects a list cell from > > the input list that > > cell can be garbage collected. If the input list is > > being retained for > > some other reason then reverse will take linear space. > > > > > > I don't think that's true. It must inspect the whole input > > list to give the first element of the output list, but it > > cannot garbage collect the input list because it needs to > > yield every element of it. > > reverse creates the output list by pulling items from the head of the > input list, and prefixing them to the output list. *Tail recursively! *That is a very important point.* *Let's have a closer look at an explicitly recursive version. reverse xs = go [] xs where go out [] = out go out (x:xs) = go (x:out) xs * *Now let's do a rewrite chain: reverse (enumFromTo 1 4) go [] (enumFromTo 1 4) go [] (1:enumFromTo 2 4) go (1:[]) (enumFromTo 2 4) go (1:[]) (2:enumFromTo 3 4) go (2:1:[]) (enumFromTo 3 4) go (2:1:[]) (3:enumFromTo 4 4) go (3:2:1:[]) (enumFromTo 4 4) go (3:2:1:[]) (4:enumFromTo 5 4) go (4:3:2:1:[]) (enumFromTo 5 4) go (4:3:2:1:[]) [] 4:3:2:1:[] (For sanity I skipped the number evaluation steps, but enumFromTo would have been forcing them to check for the end, so it ends up the same) We needed to construct the entire reversed list before we could see the first cons cell. There *is* a very strange implementation of reverse whose spine is as lazy as the input spine (but forcing the first element will still force the whole input spine). But it is quite odd, and certainly is not arrived at by the compiler automatically from the definition in the Prelude. I verified with -O2. length . reverse is not constant space in GHC. And there really is no reasonable way it could be (save for specific RULES pragmata). Luke After each item has > been pulled from the input, the list node can be GC'd from the input > list. Also, if the output list is itself being consumed by a function > which does not require the entire list (like length) then again the list > node can be GC'd soon after consumption. > > > > ghci> length $ reverse [1..10^7] > > This is a compiler optimisation, I think, so will probably require ghc > -O(2?). > > Alistair > ***************************************************************** > Confidentiality Note: The information contained in this message, > and any attachments, may contain confidential and/or privileged > material. It is intended solely for the person(s) or entity to > which it is addressed. Any review, retransmission, dissemination, > or taking of any action in reliance upon this information by > persons or entities other than the intended recipient(s) is > prohibited. If you received this in error, please contact the > sender and delete the material from any computer. > ***************************************************************** > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/b856a981/attachment.htm From pkeir at dcs.gla.ac.uk Fri Dec 19 11:27:52 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Fri Dec 19 11:20:27 2008 Subject: [Haskell-cafe] forkIO on multicore Message-ID: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> Hi all, I'm seeing no performance increase with a simple coarse-grained 2-thread code using Control.Concurrent. I compile with: > hc conc.hs -o conc --make -threaded and I run with > time ./conc +RTS -N2 But using either "-N1" or "-N2", the program runs in about 1.8secs. (I'd prefer a longer running thread task, but my fib function currently runs out of memory). Anyway, my program is below, and I'm using GHC version 6.8.2 on a 2-core Pentium D. Can anyone help? module Main where import Control.Concurrent fibs = 0 : 1 : zipWith (+) fibs (tail fibs) heavytask m = putMVar m (fibs !! 100000) main = do ms <- sequence $ replicate 2 newEmptyMVar mapM_ (forkIO . heavytask) $ tail ms heavytask $ head ms ms' <- mapM takeMVar ms mapM_ print ms' Regards, Paul From felipe.lessa at gmail.com Fri Dec 19 11:31:20 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Dec 19 11:23:50 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> Message-ID: On Fri, Dec 19, 2008 at 2:27 PM, Paul Keir wrote: > I'm seeing no performance increase with a simple coarse-grained > 2-thread code using Control.Concurrent. I compile with: I didn't test your code, but [...] > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > heavytask m = putMVar m (fibs !! 100000) [...] probably fibs is being calculated only once, so just one thread calculates (fibs !! 100000) while others just keep waiting for the result. -- Felipe. From dons at galois.com Fri Dec 19 11:37:09 2008 From: dons at galois.com (Don Stewart) Date: Fri Dec 19 11:30:04 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> Message-ID: <20081219163709.GC14666@scytale.galois.com> pkeir: > Hi all, > > I'm seeing no performance increase with a simple coarse-grained > 2-thread code using Control.Concurrent. I compile with: > > > hc conc.hs -o conc --make -threaded Also, if you care about performance in the slightest , please use -O2 Code is typically 10-30x faster with optimisations on. -- Don From lrpalmer at gmail.com Fri Dec 19 11:39:26 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Dec 19 11:31:57 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> Message-ID: <7ca3f0160812190839p3f027f55k6d5996ddf7d75899@mail.gmail.com> On Fri, Dec 19, 2008 at 9:27 AM, Paul Keir wrote: > Hi all, > > I'm seeing no performance increase with a simple coarse-grained > 2-thread code using Control.Concurrent. I compile with: > > > hc conc.hs -o conc --make -threaded > > and I run with > > > time ./conc +RTS -N2 > > But using either "-N1" or "-N2", the program runs in about 1.8secs. > (I'd prefer a longer running thread task, but my fib function > currently runs out of memory). > > Anyway, my program is below, and I'm using GHC version 6.8.2 on > a 2-core Pentium D. Can anyone help? > > module Main where > > import Control.Concurrent > > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) This is a serial algorithm. No matter what the rest of your program is doing, this calculation is sequential, so you will not see a speedup. Parallelizing computation of the fibonacci numbers is reasonably tricky. I think you might be able to do it using the fib(2n) identity. But not this simple algorithm: throwing processors at a problem does not automatically make it parallel. :-) > > heavytask m = putMVar m (fibs !! 100000) > > main = do ms <- sequence $ replicate 2 newEmptyMVar > mapM_ (forkIO . heavytask) $ tail ms > heavytask $ head ms > ms' <- mapM takeMVar ms > mapM_ print ms' > > Regards, > 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/20081219/b4ee116c/attachment.htm From jake at pikewerks.com Fri Dec 19 11:42:30 2008 From: jake at pikewerks.com (Jake McArthur) Date: Fri Dec 19 11:35:02 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> Message-ID: <494BCEF6.8090707@pikewerks.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Keir wrote: > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) This is a CAF (Constant Applicative Form). Since it is actually a constant it is never garbage collected, and is always shared, so each thread is only calculating it once. You have essentially created a lookup table. - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklLzvIACgkQye5hVyvIUKkaBACfTJfoWokgzmkyN8wm8zIeGc89 UcwAoK2VR8c0zCs0P6XTmAaJcN8oaDYc =9Yu/ -----END PGP SIGNATURE----- From lrpalmer at gmail.com Fri Dec 19 11:44:18 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Dec 19 11:36:49 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> Message-ID: <7ca3f0160812190844q6eb482c8l3b6ee70826036fe@mail.gmail.com> On Fri, Dec 19, 2008 at 9:27 AM, Paul Keir wrote: > module Main where > > import Control.Concurrent > > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > > heavytask m = putMVar m (fibs !! 100000) Oh, also, heavytask is not very heavy at all. It just writes the thunk (fibs !! 100000) into the MVar. Not a single number is added in this thread. You probably meant to have the thread evaluate its argument _before_ writing it to the variable: heavytask m = putMVar m $! (fibs !! 100000) (Or more transparently) heavytask m = let answer = fibs !! 100000 in answer `seq` putMVar m answer But as per my other comments, you will not see a speedup (in fact, you will probably see some slowdown as two threads compete to compute the same value). Luke > > > main = do ms <- sequence $ replicate 2 newEmptyMVar > mapM_ (forkIO . heavytask) $ tail ms > heavytask $ head ms > ms' <- mapM takeMVar ms > mapM_ print ms' > > Regards, > 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/20081219/fe2b66ff/attachment.htm From pkeir at dcs.gla.ac.uk Fri Dec 19 11:45:45 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Fri Dec 19 11:38:18 2008 Subject: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED] In-Reply-To: <7ca3f0160812190844q6eb482c8l3b6ee70826036fe@mail.gmail.com> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <7ca3f0160812190844q6eb482c8l3b6ee70826036fe@mail.gmail.com> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C81C7191@EX2.ad.dcs.gla.ac.uk> Thanks Luke, and everyone else. Ok, back to the drawing board. Paul From: Luke Palmer [mailto:lrpalmer@gmail.com] Sent: 19 December 2008 16:44 To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED] On Fri, Dec 19, 2008 at 9:27 AM, Paul Keir wrote: module Main where import Control.Concurrent fibs = 0 : 1 : zipWith (+) fibs (tail fibs) heavytask m = putMVar m (fibs !! 100000) Oh, also, heavytask is not very heavy at all. It just writes the thunk (fibs !! 100000) into the MVar. Not a single number is added in this thread. You probably meant to have the thread evaluate its argument _before_ writing it to the variable: heavytask m = putMVar m $! (fibs !! 100000) (Or more transparently) heavytask m = let answer = fibs !! 100000 in answer `seq` putMVar m answer But as per my other comments, you will not see a speedup (in fact, you will probably see some slowdown as two threads compete to compute the same value). Luke main = do ms <- sequence $ replicate 2 newEmptyMVar mapM_ (forkIO . heavytask) $ tail ms heavytask $ head ms ms' <- mapM takeMVar ms mapM_ print ms' Regards, 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/20081219/64a8c3ab/attachment-0001.htm From Alistair.Bayley at invesco.com Fri Dec 19 11:48:05 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Dec 19 11:40:36 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: <7ca3f0160812190814r775c44cbp241563749489a033@mail.gmail.com> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> <1229700379.10115.747.camel@localhost> <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA911025D69@GBLONXMB02.corp.amvescap.net> <7ca3f0160812190814r775c44cbp241563749489a033@mail.gmail.com> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025D6A@GBLONXMB02.corp.amvescap.net> > reverse creates the output list by pulling items from > the head of the > input list, and prefixing them to the output list. > > > Tail recursively! That is a very important point. Let's have > a closer look at an explicitly recursive version. > > reverse xs = go [] xs > where > go out [] = out > go out (x:xs) = go (x:out) xs > > Now let's do a rewrite chain: > > reverse (enumFromTo 1 4) > go [] (enumFromTo 1 4) > go [] (1:enumFromTo 2 4) > go (1:[]) (enumFromTo 2 4) > go (1:[]) (2:enumFromTo 3 4) > go (2:1:[]) (enumFromTo 3 4) > go (2:1:[]) (3:enumFromTo 4 4) > go (3:2:1:[]) (enumFromTo 4 4) > go (3:2:1:[]) (4:enumFromTo 5 4) > go (4:3:2:1:[]) (enumFromTo 5 4) > go (4:3:2:1:[]) [] > 4:3:2:1:[] > > (For sanity I skipped the number evaluation steps, but > enumFromTo would have been forcing them to check for the end, > so it ends up the same) > > We needed to construct the entire reversed list before we > could see the first cons cell. > > There is a very strange implementation of reverse whose spine > is as lazy as the input spine (but forcing the first element > will still force the whole input spine). But it is quite > odd, and certainly is not arrived at by the compiler > automatically from the definition in the Prelude. > > I verified with -O2. length . reverse is not constant space > in GHC. And there really is no reasonable way it could be > (save for specific RULES pragmata). > > Luke One could also well imagine a list fusion optimisation that says: length . reverse == length I have no idea if this is applied (or even correct). I compared (with ghc 6.8, --make -O2 -prof -auto-all): main = print (length x) x :: [Int] x = [1..1000000] total alloc = 40,002,288 bytes (excludes profiling overheads) main = print (length (reverse x)) x :: [Int] x = [1..1000000] total alloc = 52,002,296 bytes (excludes profiling overheads) So the reverse has some overhead (25%). Is that what you'd expect if it was entirely constructed? Another comparison: main = print (length x) x :: [Int] x = take 1000000 (repeat 1) total alloc = 24,002,256 bytes (excludes profiling overheads) main = print (length (reverse x)) x :: [Int] x = take 1000000 (repeat 1) total alloc = 36,002,264 bytes (excludes profiling overheads) I'm not sure what this says, exactly (50% overhead?). Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From jake at pikewerks.com Fri Dec 19 11:48:39 2008 From: jake at pikewerks.com (Jake McArthur) Date: Fri Dec 19 11:41:10 2008 Subject: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED] In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7191@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <7ca3f0160812190844q6eb482c8l3b6ee70826036fe@mail.gmail.com> <3CDFB8AFEA98E34CB599475AB11589C81C7191@EX2.ad.dcs.gla.ac.uk> Message-ID: <494BD067.9020600@pikewerks.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Keir wrote: > Thanks Luke, and everyone else. Ok, back to the drawing board. You may be interested in this: http://cgi.cse.unsw.edu.au/~dons/blog/2007/11/29 - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklL0GQACgkQye5hVyvIUKmnPgCgg6dK2KeBgE0T3T1He53+jSOb SkcAoMiQTdIvqQG5At/Q+mg7Ybos4JWq =+y/+ -----END PGP SIGNATURE----- From duncan.coutts at worc.ox.ac.uk Fri Dec 19 11:48:50 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Dec 19 11:41:23 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> <1229700379.10115.747.camel@localhost> <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> Message-ID: <1229705330.10115.760.camel@localhost> On Fri, 2008-12-19 at 08:44 -0700, Luke Palmer wrote: > On Fri, Dec 19, 2008 at 8:26 AM, Duncan Coutts > > It allocates a new list cell for every cell it finds in the > input list. If the input list can be garbage collected then > reverse takes constant space because each time it inspects a > list cell from the input list that cell can be garbage > collected. If the input list is being retained for some other > reason then reverse will take linear space. > > I don't think that's true. It must inspect the whole input list to > give the first element of the output list, but it cannot garbage > collect the input list because it needs to yield every element of it. > > When I tested: > > ghci> length $ reverse [1..10^7] > > It certainly did not run in constant space. But that's because the input list took constant not linear space. I said it allocates an element for every element in the input. So it's only constant space if we can offset a linear amount of space used for the output with a linear amount of space saved from collecting the input. Try this: using the helper function: force = foldr (\x xs -> seq xs (x : xs)) [] Then we want to look at the heap space used to evaluate: head (force [1..10^6]) and compare it to: head (reverse (force [1..10^6])) We can do that using $ ghc +RTS -s -RTS -e 'expr' and looking at the "bytes maximum residency" in the GC stats. On my box (64bit) we find that the two examples use almost exactly the same maximum heap size (of about 20Mb). So that's why I was claiming reverse takes constant net memory (when the input list is evaluated and can be subsequently discarded). Duncan From lrpalmer at gmail.com Fri Dec 19 11:58:22 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Dec 19 11:50:53 2008 Subject: [Haskell-cafe] Re: sort and lazyness (?) In-Reply-To: <1229705330.10115.760.camel@localhost> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E97CF@GBLONXMB02.corp.amvescap.net> <1229700379.10115.747.camel@localhost> <7ca3f0160812190744r3129890cuc9debe87e37a43b7@mail.gmail.com> <1229705330.10115.760.camel@localhost> Message-ID: <7ca3f0160812190858i4cfe247fx6282d0a27b02b30a@mail.gmail.com> Hmm, okay. I guess there are some subtle technical jargon issues then. You're talking about space in terms of fully evaluated inputs. But whatever I used to talk about this, I would want it to distinguish the behavior of "reverse" and, say, "map id". But I suppose strictness is a better tool to talk about that difference than space complexity. I.e.: reverse (xs ++ _|_) = _|_ Luke On Fri, Dec 19, 2008 at 9:48 AM, Duncan Coutts wrote: > On Fri, 2008-12-19 at 08:44 -0700, Luke Palmer wrote: > > On Fri, Dec 19, 2008 at 8:26 AM, Duncan Coutts > > > > It allocates a new list cell for every cell it finds in the > > input list. If the input list can be garbage collected then > > reverse takes constant space because each time it inspects a > > list cell from the input list that cell can be garbage > > collected. If the input list is being retained for some other > > reason then reverse will take linear space. > > > > I don't think that's true. It must inspect the whole input list to > > give the first element of the output list, but it cannot garbage > > collect the input list because it needs to yield every element of it. > > > > When I tested: > > > > ghci> length $ reverse [1..10^7] > > > > It certainly did not run in constant space. > > But that's because the input list took constant not linear space. I said > it allocates an element for every element in the input. So it's only > constant space if we can offset a linear amount of space used for the > output with a linear amount of space saved from collecting the input. > > Try this: > > using the helper function: > force = foldr (\x xs -> seq xs (x : xs)) [] > > Then we want to look at the heap space used to evaluate: > head (force [1..10^6]) > > and compare it to: > head (reverse (force [1..10^6])) > > We can do that using $ ghc +RTS -s -RTS -e 'expr' > and looking at the "bytes maximum residency" in the GC stats. > > On my box (64bit) we find that the two examples use almost exactly the > same maximum heap size (of about 20Mb). > > So that's why I was claiming reverse takes constant net memory (when the > input list is evaluated and can be subsequently discarded). > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/b3fa25c7/attachment.htm From ccshan at post.harvard.edu Fri Dec 19 11:09:01 2008 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Fri Dec 19 11:52:57 2008 Subject: [Haskell-cafe] Re: Fwd: Haskell as a religion References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> <494A5AA5.9010806@complete.org> <494AE7A3.3000306@henning-thielemann.de> Message-ID: Henning Thielemann wrote in article <494AE7A3.3000306@henning-thielemann.de> in gmane.comp.lang.haskell.cafe: > In C/C++ referential transparent functions code can be declared by > appending a 'const' to the prototype, right? No. $ cat x.cc int f() const; int f() { return 3; } $ gcc x.cc x.cc:1: error: non-member function ???int f()??? cannot have cv-qualifier You can define a const member function, but it can call rand() just fine. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig If you want to go somewhere, goto is the best way to get there. Ken Thompson. From Alistair.Bayley at invesco.com Fri Dec 19 12:07:59 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Dec 19 12:00:33 2008 Subject: [Haskell-cafe] OT: representations for graphs Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025D6B@GBLONXMB02.corp.amvescap.net> (OT, but I'm hoping some of you might have some ideas on this anyway...) I was wondering what alternative representations there are for graphs, or maybe if there might be a way to derive one/some from some insightful observations. For the purposes of storing and exmaining (querying) graphs in an SQL database. For example, a tree (so, a specialised sub-class of graph) can be represented by a three models, that I know of: - adjacency-list (the most common) - materialised-path (a denormalisation of adjacency-list) - nested-sets Nested-sets (and materialised-path) works for trees because the graph is - directed (so we know which nodes are parents or children) - acyclic (there's a definite root, and leaves) - every child has a single parent (so no diamond shapes - does this property have a name?) Nested-sets works well with SQL databases for querying, at the expense of updates. Adjacency-list is easier to update, but some queries suck, or are downright impossible in normal SQL. We can use the adjacency-list model for graphs too, but it has the same query deficiencies as for trees. I'd like some sort of alternative to adjacency-list, like nested-sets, that would work better for querying at the expense of updates. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From tanimoto at arizona.edu Fri Dec 19 12:10:24 2008 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Fri Dec 19 12:02:54 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA9049E97D0@GBLONXMB02.corp.amvescap.net> References: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> <125EACD0CAE4D24ABDB4D148C4593DA9049E97D0@GBLONXMB02.corp.amvescap.net> Message-ID: Hello, On Fri, Dec 19, 2008 at 8:53 AM, Bayley, Alistair wrote: > That said, I also like the sloth. > > Alistair I quite like the sloth too, that would be a great mascot if you ask me. Distinctive, conveys the idea of laziness, warm & fuzzy, etc. I hope somebody can come up with a design with it. Conrad's robot idea is also appealing to me, which is funny because we're so picky about side-effects. (There's a logo with a missile in the page too.) Remember that robot mascot that Firefox had a while ago? Another idea: something in the form of an Ouroboros. Is that already "taken" for a programming language? http://en.wikipedia.org/wiki/Ouroboros I should open up my GEB again. Paulo From pkeir at dcs.gla.ac.uk Fri Dec 19 12:16:27 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Fri Dec 19 12:08:58 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <7ca3f0160812190844q6eb482c8l3b6ee70826036fe@mail.gmail.com> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <7ca3f0160812190844q6eb482c8l3b6ee70826036fe@mail.gmail.com> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C81C7192@EX2.ad.dcs.gla.ac.uk> I did indeed intend for the threads to evaluate before writing to the two variables, thanks. > heavytask m = putMVar m $! (fibs !! 100000) I now see a time difference, but as you suggested, in the wrong direction (1.5s for one, and 3.6s for two threads). I was hoping for each thread to independently calculate a fib number (but only to easily give them something to do) . Are the threads really in competition though? I'm hoping for each thread to write its own result; so giving the same answer twice. With the "-N2" and "-threaded" switches, can I not expect each thread to run on a separate core? Paul From felipe.lessa at gmail.com Fri Dec 19 12:22:00 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Dec 19 12:14:29 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7192@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <7ca3f0160812190844q6eb482c8l3b6ee70826036fe@mail.gmail.com> <3CDFB8AFEA98E34CB599475AB11589C81C7192@EX2.ad.dcs.gla.ac.uk> Message-ID: On Fri, Dec 19, 2008 at 3:16 PM, Paul Keir wrote: > can I not expect each thread to run on a separate core? Try moving 'fibs' inside 'heavyTask', like heavytask m = putMVar m $! (let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) in (fibs !! 100000)) Maybe this may trick the compiler into not sharing fibs. -- Felipe. From dvde at gmx.net Fri Dec 19 12:25:27 2008 From: dvde at gmx.net (Daniel van den Eijkel) Date: Fri Dec 19 12:17:59 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> <125EACD0CAE4D24ABDB4D148C4593DA9049E97D0@GBLONXMB02.corp.amvescap.net> Message-ID: <494BD907.20902@gmx.net> The ouroboros was used as a logo of the "second order cybernetics" by Heinz von F?rster. But I don't know of any programming language using this as logo. regards, daniel Paulo Tanimoto schrieb: > Hello, > > On Fri, Dec 19, 2008 at 8:53 AM, Bayley, Alistair > wrote: > >> That said, I also like the sloth. >> >> Alistair >> > > I quite like the sloth too, that would be a great mascot if you ask > me. Distinctive, conveys the idea of laziness, warm & fuzzy, etc. I > hope somebody can come up with a design with it. > > Conrad's robot idea is also appealing to me, which is funny because > we're so picky about side-effects. (There's a logo with a missile in > the page too.) Remember that robot mascot that Firefox had a while > ago? > > Another idea: something in the form of an Ouroboros. Is that already > "taken" for a programming language? > > http://en.wikipedia.org/wiki/Ouroboros > > I should open up my GEB again. > > Paulo > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Daniel van den Eijkel Tucholskystrasse 37 D-10117 Berlin Phone: ++49(0)30 3810 6028 Mobil: ++49(0)174 3877 266 Email: From bugfact at gmail.com Fri Dec 19 12:45:02 2008 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Dec 19 12:37:36 2008 Subject: [Haskell-cafe] Re: [reactive] problem with unamb -- doesn't kill enough threads In-Reply-To: <494B6DF1.20704@gmail.com> References: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> <494B6DF1.20704@gmail.com> Message-ID: I played a bit the the bracket function that timeout uses, but got strange results (both on Windows and OSX). Ugly code fragment follows: -%<------------------------------------------------------------------------------------------------- import Prelude hiding (catch) import Control.Concurrent import Control.Concurrent.MVar import Control.Exception import System.IO import Data.Char withThread a b = bracket (forkIO a) kill (const b) where kill id = do putStrLn ("Killing "++show id++"\n") killThread id putStrLn ("Killed "++show id++"\n") race a b = do v <- newEmptyMVar let t x = x >>= putMVar v withThread (t a) $ withThread (t b) $ takeMVar v forkPut :: IO a -> MVar a -> IO ThreadId forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler `catch` bhandler) where uhandler (ErrorCall "Prelude.undefined") = return () uhandler err = throw err bhandler BlockedOnDeadMVar = return () sleep n = do tid <- myThreadId putStrLn ("Sleeping "++show n++" sec on "++show tid++"\n") threadDelay (n*1000000) putStrLn ("Slept "++show n++" sec on "++show tid++"\n") f = sleep 2 `race` sleep 3 g = f `race` sleep 1 main = do hSetBuffering stdout LineBuffering g -%<------------------------------------------------------------------------------------------------- Here's the output when running with GHCI: C:\temp>runghc racetest Sleeping 1 sec on ThreadId 26 Sleeping 2 sec on ThreadId 27 Sleeping 3 sec on ThreadId 28 Slept 1 sec on ThreadId 26 Killing ThreadId 26 Killed ThreadId 26 Killing ThreadId 25 Killed ThreadId 25 Killing ThreadId 28 Killed ThreadId 28 Fine, all threads got killed. Here's the output from an EXE compiled with GHC -threaded, but run without +RTS -N2 C:\temp> racetest Sleeping 1 sec on ThreadId 5 Sleeping 3 sec on ThreadId 7 Sleeping 2 sec on ThreadId 6 Slept 1 sec on ThreadId 5 Killing ThreadId 5 Killed ThreadId 5 Killing ThreadId 4 Killed ThreadId 4 Killing ThreadId 7 So "Killed ThreadId 7" is not printed here. What did I do wrong? Here's the output from an EXE compiled with GHC -threaded, but run with +RTS -N2 C:\temp> racetest +RTS -N2 Sleeping 1 sec on ThreadId 5 Sleeping 3 sec on ThreadId 7 Sleeping 2 sec on ThreadId 6 Slept 1 sec on ThreadId 5 Killing ThreadId 5 Killed ThreadId 5 Killing ThreadId 4 Killed ThreadId 4 Killing ThreadId 7 Killed ThreadId 7 This works again. Is this intended behavior? Cheers, Peter Verswyvelen CTO - Anygma On Fri, Dec 19, 2008 at 10:48 AM, Simon Marlow wrote: > Sounds like you should use an exception handler so that when the parent > dies it also kills its children. Be very careful with race conditions ;-) > > For a good example of how to do this sort of thing, see > > > http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Timeout.html > > the docs are sadly missing the source links at the moment, I'm not sure > why, but you can find the source in > > http://darcs.haskell.org/packages/base/System/Timeout.hs > > Cheers, > Simon > > Conal Elliott wrote: > >> (I'm broadening the discussion to include haskell-cafe.) >> >> Andy -- What do you mean by "handling all thread forking locally"? >> >> - Conal >> >> On Thu, Dec 18, 2008 at 1:57 PM, Andy Gill > andygill@ku.edu>> wrote: >> >> Conal, et. al, >> >> I was looking for exactly this about 6~9 months ago. I got the >> suggestion to pose it as a challenge >> to the community by Duncan Coutts. What you need is thread groups, >> where for a ThreadId, you can send a signal >> to all its children, even missing generations if needed. >> I know of no way to fix this at the Haskell level without handling >> all thread forking locally. >> Perhaps a ICFP paper about the pending implementation :-) but I'm >> not sure about the research content here. >> >> Again, there is something deep about values with lifetimes. >> Andy Gill >> >> >> On Dec 18, 2008, at 3:43 PM, Conal Elliott wrote: >> >> I realized in the shower this morning that there's a serious flaw >>> in my unamb implementation as described in >>> >>> http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice. >>> I'm looking for ideas for fixing the flaw. Here's the code for >>> racing computations: >>> >>> race :: IO a -> IO a -> IO a >>> a `race` b = do v <- newEmptyMVar >>> ta <- forkPut a v >>> tb <- forkPut b v >>> x <- takeMVar v >>> killThread ta >>> killThread tb >>> return x >>> >>> forkPut :: IO a -> MVar a -> IO ThreadId >>> forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler >>> `catch` bhandler) >>> where >>> uhandler (ErrorCall "Prelude.undefined") = return () >>> uhandler err = throw err >>> bhandler BlockedOnDeadMVar = return () >>> >>> The problem is that each of the threads ta and tb may have spawned >>> other threads, directly or indirectly. When I kill them, they >>> don't get a chance to kill their sub-threads. >>> >>> Perhaps I want some form of garbage collection of threads, perhaps >>> akin to Henry Baker's paper "The Incremental Garbage Collection of >>> Processes". As with memory GC, dropping one consumer would >>> sometimes result is cascading de-allocations. That cascade is >>> missing from my implementation. >>> >>> Or maybe there's a simple and dependable manual solution, >>> enhancing the method above. >>> >>> Any ideas? >>> >>> - Conal >>> >>> >>> _______________________________________________ >>> Reactive mailing list >>> Reactive@haskell.org >>> http://www.haskell.org/mailman/listinfo/reactive >>> >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/1c0171d3/attachment.htm From duncan.coutts at worc.ox.ac.uk Fri Dec 19 12:52:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Dec 19 12:44:51 2008 Subject: [Haskell-cafe] forkIO on multicore In-Reply-To: <494BCEF6.8090707@pikewerks.com> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <494BCEF6.8090707@pikewerks.com> Message-ID: <1229709140.10115.782.camel@localhost> On Fri, 2008-12-19 at 10:42 -0600, Jake McArthur wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Paul Keir wrote: > > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > > This is a CAF (Constant Applicative Form). Since it is actually a > constant it is never garbage collected, and is always shared, so each > thread is only calculating it once. You have essentially created a > lookup table. Though note that with all our obvious suggestions there is still no speedup: heavytask m n = putMVar m $! (fibs !! 100000) where fibs = n : (n+1) : zipWith (+) fibs (tail fibs) -- so now fibs is not globally shared but is used per-heavytask -- it is also evaluated by heavy task rather than just putting a thunk -- into the MVar main = do ms <- sequence $ replicate 8 newEmptyMVar sequence_ [ forkIO (heavytask m n) | (m, n) <- zip ms [0..] ] ms' <- mapM takeMVar ms mapM_ print ms' Looking at the GC stats (+RTS -t -RTS) we see that the majority of the time in this program is spent doing GC and that when we run with -N4 the time spent doing GC is even higher. -N1 1.57 MUT (1.60 elapsed), 7.05 GC (7.16 elapsed) real 0m8.793s -N2 2.50 MUT (1.49 elapsed), 8.48 GC (7.33 elapsed) real 0m8.873s -N4 2.83 MUT (1.56 elapsed), 12.16 GC (7.95 elapsed) real 0m9.572s The process monitor indicates that in the -N1 case, one core hits 100% use for the full 8 seconds. In the -N2 case one core is hitting 90% utilisation with the other three cores doing a little work, up to about 40% utilisation. On some runs the core doing the most work swaps over. In one run at -N2 I got a segmentation fault. In the -N4 case, 4 cores hit between 30% and 80% utilisation. So this benchmark is primarily a stress test of the parallel garbage collector since it is GC that is taking 75-80% of the time. Note that the mutator elapsed time goes down slightly with 2 cores compared to 1 however the GC elapsed time goes up slightly. Duncan From nbloomf at gmail.com Fri Dec 19 13:39:29 2008 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Fri Dec 19 13:31:59 2008 Subject: [Haskell-cafe] OT: representations for graphs In-Reply-To: <9858b5620812191037p20f98b2cnafb350a547f6a86a@mail.gmail.com> References: <125EACD0CAE4D24ABDB4D148C4593DA911025D6B@GBLONXMB02.corp.amvescap.net> <9858b5620812191037p20f98b2cnafb350a547f6a86a@mail.gmail.com> Message-ID: <9858b5620812191039h12a6357bsc8a9c2c81104bd6e@mail.gmail.com> (Forgot to send to haskell-cafe- sorry Alistair!) Martin Erwig wrote a paper [1] that defines an inductive graph type and implements some common algorithms with it. Also, it isn't very Haskellish but if you can label your nodes with an instance of Ix you might be able to use an Array to get constant time access. I've never used Data.HashTable before, but that might also be useful. [1] - http://web.engr.oregonstate.edu/~erwig/papers/InductiveGraphs_JFP01.pdf -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/7931ef45/attachment.htm From jamiiecb at googlemail.com Fri Dec 19 13:45:19 2008 From: jamiiecb at googlemail.com (Jamie Brandon) Date: Fri Dec 19 13:37:50 2008 Subject: [Haskell-cafe] OT: representations for graphs In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025D6B@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA911025D6B@GBLONXMB02.corp.amvescap.net> Message-ID: <10ed1a750812191045i5dd9ef85i36a52c15a936125@mail.gmail.com> In model checking, transition matrices (ie weighted adjacency matrices) are often represented by binary decision diagrams. They're a very compact way of representing sparse or regular vectors/matrices (where graphs can be thought of as adjacency matrices). Theres some good lecture notes on them here: http://web.comlab.ox.ac.uk/teaching/materials08-09/probabilistic/19-symbolic.pdf If you skip to page 42 theres a table comparing memory use with traditional sparse representations. Jamie On Fri, Dec 19, 2008 at 5:07 PM, Bayley, Alistair wrote: > (OT, but I'm hoping some of you might have some ideas on this anyway...) > > I was wondering what alternative representations there are for graphs, > or maybe if there might be a way to derive one/some from some insightful > observations. For the purposes of storing and exmaining (querying) > graphs in an SQL database. > > For example, a tree (so, a specialised sub-class of graph) can be > represented by a three models, that I know of: > - adjacency-list (the most common) > - materialised-path (a denormalisation of adjacency-list) > - nested-sets > > Nested-sets (and materialised-path) works for trees because the graph is > - directed (so we know which nodes are parents or children) > - acyclic (there's a definite root, and leaves) > - every child has a single parent (so no diamond shapes - does this > property have a name?) > > Nested-sets works well with SQL databases for querying, at the expense > of updates. Adjacency-list is easier to update, but some queries suck, > or are downright impossible in normal SQL. > > We can use the adjacency-list model for graphs too, but it has the same > query deficiencies as for trees. I'd like some sort of alternative to > adjacency-list, like nested-sets, that would work better for querying at > the expense of updates. > > Alistair > ***************************************************************** > Confidentiality Note: The information contained in this message, > and any attachments, may contain confidential and/or privileged > material. It is intended solely for the person(s) or entity to > which it is addressed. Any review, retransmission, dissemination, > or taking of any action in reliance upon this information by > persons or entities other than the intended recipient(s) is > prohibited. If you received this in error, please contact the > sender and delete the material from any computer. > ***************************************************************** > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jamiiecb at googlemail.com Fri Dec 19 13:54:00 2008 From: jamiiecb at googlemail.com (Jamie Brandon) Date: Fri Dec 19 13:46:35 2008 Subject: [Haskell-cafe] OT: representations for graphs In-Reply-To: <10ed1a750812191045i5dd9ef85i36a52c15a936125@mail.gmail.com> References: <125EACD0CAE4D24ABDB4D148C4593DA911025D6B@GBLONXMB02.corp.amvescap.net> <10ed1a750812191045i5dd9ef85i36a52c15a936125@mail.gmail.com> Message-ID: <10ed1a750812191054t6e3f75a1i51457e9bc69c6ed0@mail.gmail.com> Oops, that url probably isnt accessible outside the department. I've attached a copy to this email, hopefully the mailing list doesnt strip attachments. On Fri, Dec 19, 2008 at 6:45 PM, Jamie Brandon wrote: > In model checking, transition matrices (ie weighted adjacency > matrices) are often represented by binary decision diagrams. They're a > very compact way of representing sparse or regular vectors/matrices > (where graphs can be thought of as adjacency matrices). Theres some > good lecture notes on them here: > > http://web.comlab.ox.ac.uk/teaching/materials08-09/probabilistic/19-symbolic.pdf > > If you skip to page 42 theres a table comparing memory use with > traditional sparse representations. > > Jamie > > On Fri, Dec 19, 2008 at 5:07 PM, Bayley, Alistair > wrote: >> (OT, but I'm hoping some of you might have some ideas on this anyway...) >> >> I was wondering what alternative representations there are for graphs, >> or maybe if there might be a way to derive one/some from some insightful >> observations. For the purposes of storing and exmaining (querying) >> graphs in an SQL database. >> >> For example, a tree (so, a specialised sub-class of graph) can be >> represented by a three models, that I know of: >> - adjacency-list (the most common) >> - materialised-path (a denormalisation of adjacency-list) >> - nested-sets >> >> Nested-sets (and materialised-path) works for trees because the graph is >> - directed (so we know which nodes are parents or children) >> - acyclic (there's a definite root, and leaves) >> - every child has a single parent (so no diamond shapes - does this >> property have a name?) >> >> Nested-sets works well with SQL databases for querying, at the expense >> of updates. Adjacency-list is easier to update, but some queries suck, >> or are downright impossible in normal SQL. >> >> We can use the adjacency-list model for graphs too, but it has the same >> query deficiencies as for trees. I'd like some sort of alternative to >> adjacency-list, like nested-sets, that would work better for querying at >> the expense of updates. >> >> Alistair >> ***************************************************************** >> Confidentiality Note: The information contained in this message, >> and any attachments, may contain confidential and/or privileged >> material. It is intended solely for the person(s) or entity to >> which it is addressed. Any review, retransmission, dissemination, >> or taking of any action in reliance upon this information by >> persons or entities other than the intended recipient(s) is >> prohibited. If you received this in error, please contact the >> sender and delete the material from any computer. >> ***************************************************************** >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > -------------- next part -------------- A non-text attachment was scrubbed... Name: bdd.pdf Type: application/pdf Size: 292465 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/f54bd8fd/bdd-0001.pdf From conal at conal.net Fri Dec 19 14:17:15 2008 From: conal at conal.net (Conal Elliott) Date: Fri Dec 19 14:09:46 2008 Subject: [Haskell-cafe] Re: [reactive] problem with unamb -- doesn't kill enough threads In-Reply-To: References: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> <494B6DF1.20704@gmail.com> Message-ID: Peter, Thanks for digging. In your results below, I see only three out of four threads killed even in the best case. Each time, there is no report of the 'sleep 2' thread being killed. When I run your code on Linux (Ubuntu 8.10), everything looks great when run under ghci. If compiled, with and without -threaded and with and without +RTS -N2, I sometimes get four kill messages and sometimes fewer. In the latter case, I don't know if the other threads aren't getting killed or if they're killed but not reported. For example (removing messages other than "Killed"): conal@compy-doble:~/Haskell/Misc$ rm Threads.o ; ghc Threads.hs -threaded -o Threads && ./Threads +RTS -N2 Killed ThreadId 5 Killed ThreadId 4 conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 Killed ThreadId 5 Killed ThreadId 4 Killed ThreadId 7 Killed ThreadId 6 conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 Killed ThreadId 5 Killed ThreadId 7 Killed ThreadId 4 Killed ThreadId 6 conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 Killed ThreadId 5 Killed ThreadId 4 conal@compy-doble:~/Haskell/Misc$ Simon -- does this behavior look like a GHC bug to you? - Conal On Fri, Dec 19, 2008 at 9:45 AM, Peter Verswyvelen wrote: > I played a bit the the bracket function that timeout uses, but got strange > results (both on Windows and OSX). > > Ugly code fragment follows: > > > -%<------------------------------------------------------------------------------------------------- > > import Prelude hiding (catch) > > import Control.Concurrent > import Control.Concurrent.MVar > import Control.Exception > import System.IO > import Data.Char > > withThread a b = bracket (forkIO a) kill (const b) > where > kill id = do > putStrLn ("Killing "++show id++"\n") > killThread id > putStrLn ("Killed "++show id++"\n") > > race a b = do > v <- newEmptyMVar > let t x = x >>= putMVar v > withThread (t a) $ withThread (t b) $ takeMVar v > > forkPut :: IO a -> MVar a -> IO ThreadId > forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler `catch` > bhandler) > where > uhandler (ErrorCall "Prelude.undefined") = return () > uhandler err = throw err > bhandler BlockedOnDeadMVar = return () > > sleep n = do > tid <- myThreadId > putStrLn ("Sleeping "++show n++" sec on "++show tid++"\n") > threadDelay (n*1000000) > putStrLn ("Slept "++show n++" sec on "++show tid++"\n") > > f = sleep 2 `race` sleep 3 > > g = f `race` sleep 1 > > main = do > hSetBuffering stdout LineBuffering > g > > > -%<------------------------------------------------------------------------------------------------- > > Here's the output when running with GHCI: > > C:\temp>runghc racetest > Sleeping 1 sec on ThreadId 26 > Sleeping 2 sec on ThreadId 27 > Sleeping 3 sec on ThreadId 28 > Slept 1 sec on ThreadId 26 > Killing ThreadId 26 > Killed ThreadId 26 > Killing ThreadId 25 > Killed ThreadId 25 > Killing ThreadId 28 > Killed ThreadId 28 > > Fine, all threads got killed. > > Here's the output from an EXE compiled with GHC -threaded, but run without > +RTS -N2 > > C:\temp> racetest > Sleeping 1 sec on ThreadId 5 > Sleeping 3 sec on ThreadId 7 > Sleeping 2 sec on ThreadId 6 > Slept 1 sec on ThreadId 5 > Killing ThreadId 5 > Killed ThreadId 5 > Killing ThreadId 4 > Killed ThreadId 4 > Killing ThreadId 7 > > So "Killed ThreadId 7" is not printed here. What did I do wrong? > > Here's the output from an EXE compiled with GHC -threaded, but run with > +RTS -N2 > > C:\temp> racetest +RTS -N2 > Sleeping 1 sec on ThreadId 5 > Sleeping 3 sec on ThreadId 7 > Sleeping 2 sec on ThreadId 6 > Slept 1 sec on ThreadId 5 > > Killing ThreadId 5 > Killed ThreadId 5 > Killing ThreadId 4 > Killed ThreadId 4 > Killing ThreadId 7 > Killed ThreadId 7 > > This works again. > > Is this intended behavior? > > Cheers, > Peter Verswyvelen > CTO - Anygma > > On Fri, Dec 19, 2008 at 10:48 AM, Simon Marlow wrote: > >> Sounds like you should use an exception handler so that when the parent >> dies it also kills its children. Be very careful with race conditions ;-) >> >> For a good example of how to do this sort of thing, see >> >> >> http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Timeout.html >> >> the docs are sadly missing the source links at the moment, I'm not sure >> why, but you can find the source in >> >> http://darcs.haskell.org/packages/base/System/Timeout.hs >> >> Cheers, >> Simon >> >> Conal Elliott wrote: >> >>> (I'm broadening the discussion to include haskell-cafe.) >>> >>> Andy -- What do you mean by "handling all thread forking locally"? >>> >>> - Conal >>> >>> On Thu, Dec 18, 2008 at 1:57 PM, Andy Gill >> andygill@ku.edu>> wrote: >>> >>> Conal, et. al, >>> >>> I was looking for exactly this about 6~9 months ago. I got the >>> suggestion to pose it as a challenge >>> to the community by Duncan Coutts. What you need is thread groups, >>> where for a ThreadId, you can send a signal >>> to all its children, even missing generations if needed. >>> I know of no way to fix this at the Haskell level without handling >>> all thread forking locally. >>> Perhaps a ICFP paper about the pending implementation :-) but I'm >>> not sure about the research content here. >>> >>> Again, there is something deep about values with lifetimes. >>> Andy Gill >>> >>> >>> On Dec 18, 2008, at 3:43 PM, Conal Elliott wrote: >>> >>> I realized in the shower this morning that there's a serious flaw >>>> in my unamb implementation as described in >>>> >>>> http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice. >>>> I'm looking for ideas for fixing the flaw. Here's the code for >>>> racing computations: >>>> >>>> race :: IO a -> IO a -> IO a >>>> a `race` b = do v <- newEmptyMVar >>>> ta <- forkPut a v >>>> tb <- forkPut b v >>>> x <- takeMVar v >>>> killThread ta >>>> killThread tb >>>> return x >>>> >>>> forkPut :: IO a -> MVar a -> IO ThreadId >>>> forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler >>>> `catch` bhandler) >>>> where >>>> uhandler (ErrorCall "Prelude.undefined") = return () >>>> uhandler err = throw err >>>> bhandler BlockedOnDeadMVar = return () >>>> >>>> The problem is that each of the threads ta and tb may have spawned >>>> other threads, directly or indirectly. When I kill them, they >>>> don't get a chance to kill their sub-threads. >>>> >>>> Perhaps I want some form of garbage collection of threads, perhaps >>>> akin to Henry Baker's paper "The Incremental Garbage Collection of >>>> Processes". As with memory GC, dropping one consumer would >>>> sometimes result is cascading de-allocations. That cascade is >>>> missing from my implementation. >>>> >>>> Or maybe there's a simple and dependable manual solution, >>>> enhancing the method above. >>>> >>>> Any ideas? >>>> >>>> - Conal >>>> >>>> >>>> _______________________________________________ >>>> Reactive mailing list >>>> Reactive@haskell.org >>>> http://www.haskell.org/mailman/listinfo/reactive >>>> >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/6d2eac74/attachment.htm From tonyhannan2 at gmail.com Fri Dec 19 14:48:37 2008 From: tonyhannan2 at gmail.com (Tony Hannan) Date: Fri Dec 19 14:41:08 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <856033f20812190631x70854644t421f56c1c7f05872@mail.gmail.com> References: <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> <856033f20812190631x70854644t421f56c1c7f05872@mail.gmail.com> Message-ID: Hi guys, Thanks for the comments and lively discussion. After reading these posts, a few papers, and Conal's blogs, I'm going to try Reactive because it is newer and thus likely to incorporate most of the good things from past FRP sytems including Yampa, actively being developed, and mature enough to start using now. I'll see you on the Reactive mailing list. Cheers, Tony -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/0ef3a169/attachment.htm From conal at conal.net Fri Dec 19 15:01:01 2008 From: conal at conal.net (Conal Elliott) Date: Fri Dec 19 14:53:32 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <856033f20812190631x70854644t421f56c1c7f05872@mail.gmail.com> References: <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> <856033f20812190631x70854644t421f56c1c7f05872@mail.gmail.com> Message-ID: > > The example Henrik gave [...] models a composition, and is in general the > strength of a > combinator approach. But the strength of Applicative, in my opinion, > is not composition but currying [...] > Well put, Paul. I really do like the semantic model of Yampa. Signal transformers model interactive behaviors, where the behaviors/signals of classic FRP model non-interactive behaviors. (See http://conal.net/blog/posts/why-classic-frp-does-not-fit-interactive-behavior/.) I also like currying. As long as we use not just the arrow abstraction but also *arrow notation*, I don't know how we'll ever be able to get an efficient implementation, in which portions of computed signals get recomputed only when necessary. And probably the Arrow abstraction itself is a bit too restrictive, given that it disallows any conditions on its type arguments. So I've been noodling some about formulations of signal functions that don't fit into the standard arrow discipline. Regards, - Conal On Fri, Dec 19, 2008 at 6:31 AM, Paul L wrote: > Nice to see this discussion, and I just want to comment on the > applicative v.s. arrow style. The example Henrik gave is > > z <- sf2 <<< sf1 -< x > > which models a composition, and is in general the strength of a > combinator approach. But the strength of Applicative, in my opinion, > is not composition but currying: > > f <*> x <*> y > > where f can have the type Behavior a -> Behavior b -> Behavior c. I > don't think there is an exact match in arrows. One could, however, > require sf to be of type SF (a, b) c, and write > > z <- sf -< (x, y) > > The tupling may seem an extra burden, but it's an inherent design > choice of arrows, which builds data structure on top of products, and > people can't run away from it when writing arrow programs. > > -- > Regards, > Paul Liu > > Yale Haskell Group > http://www.haskell.org/yale > _______________________________________________ > 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/20081219/567c00db/attachment.htm From conal at conal.net Fri Dec 19 15:10:27 2008 From: conal at conal.net (Conal Elliott) Date: Fri Dec 19 15:02:57 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: References: <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> <856033f20812190631x70854644t421f56c1c7f05872@mail.gmail.com> Message-ID: Hi Tony, I'm glad for your interest in Reactive. Yes, it is certainly being developed actively. To start you off with realistic expectations, I'd like you to know that Reactive currently has one or more sneaky laziness bugs that block serious application at the moment. While the Reactive implementation is almost entirely pure (free of IO), it has some quite subtle aspects, and it's taking a while to get it solid. There's also a new higher-level programming model on the way, as hinted at in my blog. Welcome! - Conal 2008/12/19 Tony Hannan > Hi guys, > > Thanks for the comments and lively discussion. After reading these posts, a > few papers, and Conal's blogs, I'm going to try Reactive because it is newer > and thus likely to incorporate most of the good things from past FRP sytems > including Yampa, actively being developed, and mature enough to start using > now. > > I'll see you on the Reactive mailing list. > > Cheers, > Tony > > > _______________________________________________ > 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/20081219/4dfb9aad/attachment.htm From frantisek.kocun at gmail.com Fri Dec 19 15:26:32 2008 From: frantisek.kocun at gmail.com (frantisek kocun) Date: Fri Dec 19 15:19:01 2008 Subject: [Haskell-cafe] Incremental trasnformations (not Haskell topic) Message-ID: Hi, this is not a Haskell question but I'm not sure if anyone in java community can answer this. And I'm sure every Haskell programmer know OO programing. I'm programming one big boring db application and making a MDD tool to model and generate such applications. Many times object have computed attributes: E.g. value attribute of class Invoice is sum of values of all associated classes Item (Invoice 1 <>---> * Item) So value attribute of invoice is computed every time it is demanded. So far easy.Sometimes it is necessary not to compute it when it is needed but to have it precomputed (computed it every time, item is added/removed to invoice or item value is changed). Contract of attribute value is the same but it is not obvious from code if you program it in event-based as if you program it with expression which is computed every time. Event-based=no big picture. Expression=big picture but little performance. Question: Is there any way how to transform the OO transformation (invoice value is a sum of values of items) to incremental transformation (update invoice value, when item is created/deleted/changed)? Is there any product doing it. I am not interesting in product itself I want only see how it works? Is there any science paper on this? I call this not a function but a OO transformation because it can be much more complicated. I know it is not possible for all the functions (transformations), you have to do undo step, but it is possible for that what we use. One more complicated example: Provider provides money to receiver. It provides money with special code. Receiver sees all the money from all the providers grouped by the code and summed. Every summed group on the code has a subgroup summed on the provider. Provider A provides to R 10 on code "ABC" Provider A provides to Q 10 on code "ABC" Provider A provides to R 5 on code "ABC" Provider A provides to R 20 on code "DEF" Provider B provides to R 30 on code "ABC" Reciever R - recieves 45 on code "ABC", 15 from A, 30 from B - recieves 20 on code "DEF", 20 from A Reciever Q - recieves 10 on code "ABC", 10 from A This example can be easily programmed declarative way in Scala the way that everytime everything is computed. But have no clue if it can be transformed automatically to incremental way. Hope you understand what I mean. Thanks for your help and opinions Fero -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/46d4dda9/attachment.htm From jgbailey at gmail.com Fri Dec 19 15:53:19 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Fri Dec 19 15:45:49 2008 Subject: [Haskell-cafe] Using cabal to build an exportable library? Message-ID: I've been following this instructions at http://www.haskell.org/haskellwiki/Calling_Haskell_from_C to build a Haskell library which I can call from a C program. I'd like to use cabal to do the build in the future. Are there any examples showing how to do it? From porges at porg.es Fri Dec 19 17:12:46 2008 From: porges at porg.es (George Pollard) Date: Fri Dec 19 17:05:21 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: Message-ID: <1229724766.6823.3.camel@porges-laptop> On Fri, 2008-12-19 at 00:10 -0800, Ashley Yakeley wrote: > I browsed around a bit for logos from other languages... > ... > All of these get one thing right that the current and most of the > proposed Haskell logos do not: they don't make any reference to the > syntax of the language itself. Doing so seems to miss the point of a > logo: it's supposed to appeal visually, rather than semantically. So I'd > like to see some submissions that don't use lambdas. I commented on this to Cale; > ... the mountain is the only real 'iconic' one :), ruby has a ruby, > python has pythons, java has its coffee, lua has the moon, Scheme had > the lambda before Haskell, perl has its (de facto) camel, etc. C(++|#) > and older languages tend to be the odd ones out This is why I like Cale's mountain (which incorporates a sneaky lambda ;P). A mountain peak/summit/apex also has nice connotations! http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas#Cale_Gibbard -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/720b119b/attachment.bin From ninegua at gmail.com Fri Dec 19 17:53:03 2008 From: ninegua at gmail.com (Paul L) Date: Fri Dec 19 17:45:34 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: References: <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> <856033f20812190631x70854644t421f56c1c7f05872@mail.gmail.com> Message-ID: <856033f20812191453x6ca05d15sca458db35b1cb6ef@mail.gmail.com> On 12/19/08, Conal Elliott wrote: > > As long as we use not just the arrow abstraction but also *arrow notation*, > I don't know how we'll ever be able to get an efficient implementation, in > which portions of computed signals get recomputed only when necessary. And > probably the Arrow abstraction itself is a bit too restrictive, given that > it disallows any conditions on its type arguments. So I've been noodling > some about formulations of signal functions that don't fit into the standard > arrow discipline. Paul (Hudak) and I recently worked on a notion called Causal Commutative Arrows, which actually gave a very good optimization result for Yampa like arrows. One notable feature is that all programs normalize, regardless of whether they were originally written using the Arrow combinators or translated from Arrow notations. I recently give a talk at NEPLS on this, the slides are here: http://www.cs.yale.edu/homes/hl293/download/NEPLS-talk.pdf Due to the use of arrow laws, our technique remains fully abstract without committing to any concrete representation of arrows or signals/streams. The re-computation problem is another issue though. I fully agree with Henrik's comment on push v.s. pull. But if one really wants to avoid re-computation at all efforts, here is one possibility: pass :: SF a b -> SF (Maybe a) (Maybe b) It'll only invoke the given SF when the input is Just something, and do nothing otherwise. Coupled with hold, it shall lead to efficient implementation that avoids re-computation when inputs don't change. Intuitively it's like selectively turning on/off part of a circuit according to inputs, which naturally falls in the ArrowChoice class. Also one has to extract the implicit time from the inplementation and make it an explicit input in order for this to be semantically sound. -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From jonathanccast at fastmail.fm Fri Dec 19 18:08:25 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Dec 19 18:00:58 2008 Subject: intimidating terminology (was: Re: [Haskell-cafe] Time for a new logo?) In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> <494B05A1.4070306@freegeek.org> Message-ID: <1229728105.20753.6.camel@jonathans-macbook> On Fri, 2008-12-19 at 09:13 +0000, Lennart Augustsson wrote: > When accurate names for Haskell concepts already exist we should use > them (as we have tried in the past). There has been too much > invention of misleading terminology in computing already. There are two possible cases (this applies to any branch of mathematics, or mathematical discipline): a) Use existing words, and give them new meanings. Then you're using a word that already means something else. Best example: series vs. sequence in calculus. b) Invent a new word (probably based on Latin or Greek roots). Then you're using incomprehensible and frightening technical jargon. Best example: catamorphism (apparently). So you're damned if you do, damned if you don't. My solution: stop caring what people think. jcc From gwern0 at gmail.com Fri Dec 19 19:08:57 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Dec 19 19:01:28 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: <1229724766.6823.3.camel@porges-laptop> References: <1229724766.6823.3.camel@porges-laptop> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 2008/12/19 George Pollard : > On Fri, 2008-12-19 at 00:10 -0800, Ashley Yakeley wrote: >> I browsed around a bit for logos from other languages... >> ... >> All of these get one thing right that the current and most of the >> proposed Haskell logos do not: they don't make any reference to the >> syntax of the language itself. Doing so seems to miss the point of a >> logo: it's supposed to appeal visually, rather than semantically. So I'd >> like to see some submissions that don't use lambdas. > > I commented on this to Cale; > >> ... the mountain is the only real 'iconic' one :), ruby has a ruby, >> python has pythons, java has its coffee, lua has the moon, Scheme had >> the lambda before Haskell, perl has its (de facto) camel, etc. C(++|#) >> and older languages tend to be the odd ones out > > This is why I like Cale's mountain (which incorporates a sneaky > lambda ;P). A mountain peak/summit/apex also has nice connotations! > > http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas#Cale_Gibbard Such as few people being able to breathe at their rarefied heights? :) Well, at least it isn't a white tower of some sort... - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklMN5IACgkQvpDo5Pfl1oIfrQCfdyRqmL55M4noKc3Zbz7VYYW1 WeUAn2EkO5BhQE03wtbtW+vwsIRRmfZZ =sdjS -----END PGP SIGNATURE----- From ashley at semantic.org Sat Dec 20 00:10:54 2008 From: ashley at semantic.org (Ashley Yakeley) Date: Sat Dec 20 00:03:27 2008 Subject: [Haskell-cafe] Re: Logos of Other Languages In-Reply-To: <1229724766.6823.3.camel@porges-laptop> References: <1229724766.6823.3.camel@porges-laptop> Message-ID: <494C7E5E.3050009@semantic.org> George Pollard wrote: > This is why I like Cale's mountain (which incorporates a sneaky > lambda ;P). A mountain peak/summit/apex also has nice connotations! > > http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas#Cale_Gibbard I think it would be better without the lambda. In fact, many of the logos would be improved simply by removing all trace of lambdas and other syntactical elements. -- Ashley From conal at conal.net Sat Dec 20 00:25:49 2008 From: conal at conal.net (Conal Elliott) Date: Sat Dec 20 00:18:21 2008 Subject: [Haskell-cafe] Re: [reactive] problem with unamb -- doesn't kill enough threads In-Reply-To: References: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> <494B6DF1.20704@gmail.com> Message-ID: Oh -- I think the problem here was simply that the process itself exited before all of the threads had a chance to get killed. When I add a short sleep to the end of main, or even just a 'yield', I see that all threads reported as killed. What clued me in was finally paying attention to the observation that under ghci I get the new prompt *before* some of the kill reports. - Conal On Fri, Dec 19, 2008 at 11:17 AM, Conal Elliott wrote: > Peter, > > Thanks for digging. In your results below, I see only three out of four > threads killed even in the best case. Each time, there is no report of the > 'sleep 2' thread being killed. > > When I run your code on Linux (Ubuntu 8.10), everything looks great when > run under ghci. If compiled, with and without -threaded and with and > without +RTS -N2, I sometimes get four kill messages and sometimes fewer. > In the latter case, I don't know if the other threads aren't getting killed > or if they're killed but not reported. > > For example (removing messages other than "Killed"): > > conal@compy-doble:~/Haskell/Misc$ rm Threads.o ; ghc Threads.hs > -threaded -o Threads && ./Threads +RTS -N2 > Killed ThreadId 5 > Killed ThreadId 4 > > conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 > Killed ThreadId 5 > Killed ThreadId 4 > Killed ThreadId 7 > Killed ThreadId 6 > > conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 > Killed ThreadId 5 > Killed ThreadId 7 > Killed ThreadId 4 > Killed ThreadId 6 > > conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 > Killed ThreadId 5 > Killed ThreadId 4 > > conal@compy-doble:~/Haskell/Misc$ > > Simon -- does this behavior look like a GHC bug to you? > > - Conal > > > On Fri, Dec 19, 2008 at 9:45 AM, Peter Verswyvelen wrote: > >> I played a bit the the bracket function that timeout uses, but got strange >> results (both on Windows and OSX). >> >> Ugly code fragment follows: >> >> >> -%<------------------------------------------------------------------------------------------------- >> >> import Prelude hiding (catch) >> >> import Control.Concurrent >> import Control.Concurrent.MVar >> import Control.Exception >> import System.IO >> import Data.Char >> >> withThread a b = bracket (forkIO a) kill (const b) >> where >> kill id = do >> putStrLn ("Killing "++show id++"\n") >> killThread id >> putStrLn ("Killed "++show id++"\n") >> >> race a b = do >> v <- newEmptyMVar >> let t x = x >>= putMVar v >> withThread (t a) $ withThread (t b) $ takeMVar v >> >> forkPut :: IO a -> MVar a -> IO ThreadId >> forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler `catch` >> bhandler) >> where >> uhandler (ErrorCall "Prelude.undefined") = return () >> uhandler err = throw err >> bhandler BlockedOnDeadMVar = return () >> >> sleep n = do >> tid <- myThreadId >> putStrLn ("Sleeping "++show n++" sec on "++show tid++"\n") >> threadDelay (n*1000000) >> putStrLn ("Slept "++show n++" sec on "++show tid++"\n") >> >> f = sleep 2 `race` sleep 3 >> >> g = f `race` sleep 1 >> >> main = do >> hSetBuffering stdout LineBuffering >> g >> >> >> -%<------------------------------------------------------------------------------------------------- >> >> Here's the output when running with GHCI: >> >> C:\temp>runghc racetest >> Sleeping 1 sec on ThreadId 26 >> Sleeping 2 sec on ThreadId 27 >> Sleeping 3 sec on ThreadId 28 >> Slept 1 sec on ThreadId 26 >> Killing ThreadId 26 >> Killed ThreadId 26 >> Killing ThreadId 25 >> Killed ThreadId 25 >> Killing ThreadId 28 >> Killed ThreadId 28 >> >> Fine, all threads got killed. >> >> Here's the output from an EXE compiled with GHC -threaded, but run without >> +RTS -N2 >> >> C:\temp> racetest >> Sleeping 1 sec on ThreadId 5 >> Sleeping 3 sec on ThreadId 7 >> Sleeping 2 sec on ThreadId 6 >> Slept 1 sec on ThreadId 5 >> Killing ThreadId 5 >> Killed ThreadId 5 >> Killing ThreadId 4 >> Killed ThreadId 4 >> Killing ThreadId 7 >> >> So "Killed ThreadId 7" is not printed here. What did I do wrong? >> >> Here's the output from an EXE compiled with GHC -threaded, but run with >> +RTS -N2 >> >> C:\temp> racetest +RTS -N2 >> Sleeping 1 sec on ThreadId 5 >> Sleeping 3 sec on ThreadId 7 >> Sleeping 2 sec on ThreadId 6 >> Slept 1 sec on ThreadId 5 >> >> Killing ThreadId 5 >> Killed ThreadId 5 >> Killing ThreadId 4 >> Killed ThreadId 4 >> Killing ThreadId 7 >> Killed ThreadId 7 >> >> This works again. >> >> Is this intended behavior? >> >> Cheers, >> Peter Verswyvelen >> CTO - Anygma >> >> On Fri, Dec 19, 2008 at 10:48 AM, Simon Marlow wrote: >> >>> Sounds like you should use an exception handler so that when the parent >>> dies it also kills its children. Be very careful with race conditions ;-) >>> >>> For a good example of how to do this sort of thing, see >>> >>> >>> http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Timeout.html >>> >>> the docs are sadly missing the source links at the moment, I'm not sure >>> why, but you can find the source in >>> >>> http://darcs.haskell.org/packages/base/System/Timeout.hs >>> >>> Cheers, >>> Simon >>> >>> Conal Elliott wrote: >>> >>>> (I'm broadening the discussion to include haskell-cafe.) >>>> >>>> Andy -- What do you mean by "handling all thread forking locally"? >>>> >>>> - Conal >>>> >>>> On Thu, Dec 18, 2008 at 1:57 PM, Andy Gill >>> andygill@ku.edu>> wrote: >>>> >>>> Conal, et. al, >>>> >>>> I was looking for exactly this about 6~9 months ago. I got the >>>> suggestion to pose it as a challenge >>>> to the community by Duncan Coutts. What you need is thread groups, >>>> where for a ThreadId, you can send a signal >>>> to all its children, even missing generations if needed. >>>> I know of no way to fix this at the Haskell level without handling >>>> all thread forking locally. >>>> Perhaps a ICFP paper about the pending implementation :-) but I'm >>>> not sure about the research content here. >>>> >>>> Again, there is something deep about values with lifetimes. >>>> Andy Gill >>>> >>>> >>>> On Dec 18, 2008, at 3:43 PM, Conal Elliott wrote: >>>> >>>> I realized in the shower this morning that there's a serious flaw >>>>> in my unamb implementation as described in >>>>> >>>>> http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice. >>>>> I'm looking for ideas for fixing the flaw. Here's the code for >>>>> racing computations: >>>>> >>>>> race :: IO a -> IO a -> IO a >>>>> a `race` b = do v <- newEmptyMVar >>>>> ta <- forkPut a v >>>>> tb <- forkPut b v >>>>> x <- takeMVar v >>>>> killThread ta >>>>> killThread tb >>>>> return x >>>>> >>>>> forkPut :: IO a -> MVar a -> IO ThreadId >>>>> forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler >>>>> `catch` bhandler) >>>>> where >>>>> uhandler (ErrorCall "Prelude.undefined") = return () >>>>> uhandler err = throw err >>>>> bhandler BlockedOnDeadMVar = return () >>>>> >>>>> The problem is that each of the threads ta and tb may have spawned >>>>> other threads, directly or indirectly. When I kill them, they >>>>> don't get a chance to kill their sub-threads. >>>>> >>>>> Perhaps I want some form of garbage collection of threads, perhaps >>>>> akin to Henry Baker's paper "The Incremental Garbage Collection of >>>>> Processes". As with memory GC, dropping one consumer would >>>>> sometimes result is cascading de-allocations. That cascade is >>>>> missing from my implementation. >>>>> >>>>> Or maybe there's a simple and dependable manual solution, >>>>> enhancing the method above. >>>>> >>>>> Any ideas? >>>>> >>>>> - Conal >>>>> >>>>> >>>>> _______________________________________________ >>>>> Reactive mailing list >>>>> Reactive@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/reactive >>>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------ >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/2cf5562c/attachment.htm From wren at freegeek.org Sat Dec 20 01:06:10 2008 From: wren at freegeek.org (wren ng thornton) Date: Sat Dec 20 00:58:40 2008 Subject: [Haskell-cafe] ANN: bytestring-trie 0.1.0 Message-ID: <494C8B52.2040209@freegeek.org> -------------------------------------------- -- Announcing: bytestring-trie 0.1.0 (beta) -------------------------------------------- An efficient finite map from (byte)strings to values. The implementation is based on big-endian patricia trees, like Data.IntMap. We first trie on the Word8 elements of a Data.ByteString, sharing string prefixes where possible, and then trie on the big-endian bit representation of those elements. Patricia trees have efficient algorithms for union and other merging operations, but they're also quick for lookups and insertions. -------------------------------------------- -- Future Extensions -------------------------------------------- * I've done spot checking to make sure it works, but haven't constructed an extensive test suite. Does anyone know of a good data set already out there for testing corner cases? I'm sure other dictionary writers have come up with one. * A Word8 is much smaller than the architecture's natural Word size. Therefore it'd be more efficient for the trie on bits to read off a whole Word at a time. This work is in progress, but I need help from people with 64-bit and big-endian machines in order to verify the code works on those architectures. * Using ByteStrings allows for trieing on any packed byte representation of a value, but they're not Strings. Integration with Data.ByteString.Char8, utf8-string, and utf8-light should happen. * The current implementation also only accepts strict ByteStrings. When chopping up strings to share prefixes we share the smaller string. For very long strings when many deletions are expected, this can still hold onto more memory than necessary. Accepting lazy ByteStrings or adding heuristics for when to copy prefixes instead of sharing will fix this. -------------------------------------------- -- Links -------------------------------------------- Homepage: http://code.haskell.org/~wren/ Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie Darcs: http://code.haskell.org/~wren/bytestring-trie/ Haddock (Darcs version): http://code.haskell.org/~wren/bytestring-trie/dist/doc/html/bytestring-trie/ -- Live well, ~wren From wren at freegeek.org Sat Dec 20 01:30:22 2008 From: wren at freegeek.org (wren ng thornton) Date: Sat Dec 20 01:22:52 2008 Subject: [Haskell-cafe] Re: Detecting system endianness In-Reply-To: References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> <200812181403.40459.holgersiegel74@yahoo.de> <494B168C.8020900@freegeek.org> Message-ID: <494C90FE.7010002@freegeek.org> Maur??cio wrote: > But why would you want that? I understand the only > situation when talking about number of bytes > makes sense is when you are using Foreign and > Ptr. Besides that, you can only guess the amount > of memory you need to deal with your data (taking > laziness, GC etc. into account). Because I'm using both Ptr and Foreign? ;) See my recent announcement for bytestring-trie. One of the optimizations I'm working on is to read off a full natural word at a time, instead of just one byte. To do this properly I need to detect the word size so that I don't accidentally read garbage off the end of the ByteString when there's less than a natural word left. Detecting endianness is similar because it determines how to interpret that word as if it were an array of bytes, which is needed to get the correct behavior when interpreting the word as a bit-vector for trieing. That is, if you only read the "first" two bytes on a big-endian machine, then you're skipping the 4/6/? bytes which are actually at the beginning of the bytestring. I'm not sure how important physical endianness of bytes within a word is. For IntMap a common case is to get large contiguous chunks of keys, so logical big-endian trieing improves performance over logical little-endian. I'm not sure how common large contiguous chunks of bytestring keys are, though. Reading a word then changing the physical endianness of the bytes seems expensive. -- Live well, ~wren From mail at justinbogner.com Sat Dec 20 01:30:26 2008 From: mail at justinbogner.com (mail@justinbogner.com) Date: Sat Dec 20 01:23:09 2008 Subject: [Haskell-cafe] Re: Logos of Other Languages References: Message-ID: <87tz8ztl31.fsf@justinbogner.com> Ashley Yakeley writes: > All of these get one thing right that the current and most of the > proposed Haskell logos do not: they don't make any reference to the > syntax of the language itself. Doing so seems to miss the point of a > logo: it's supposed to appeal visually, rather than semantically. So > I'd like to see some submissions that don't use lambdas. All of these, in fact, make absolutely no reference to any part of the language itself, other than the title. Should we then use a portrait of Haskell Curry as the logo? I have no problem with a logo that doesn't have a lambda, but I don't think the fact that using a lambda is (almost) putting syntax in a logo should be considered a problem. An homage to syntax at least gives an easily recognizable icon, far more iconic than a camel or a grid of colours, and I would consider several of the lambda based ideas on the wiki simple, elegant and visually appealing. From jason.dusek at gmail.com Sat Dec 20 04:11:31 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat Dec 20 04:04:00 2008 Subject: [Haskell-cafe] understanding enumerator/iteratee Message-ID: <42784f260812200111y320fafd4ja8d8bb1a52573808@mail.gmail.com> So, it looks Iteratee takes a "step" on the resource -- whatever it is -- and Enumerator manages the resource and sequences the steps of the Iteratee. The Enumerator, then, defines our way of managing a particular resource -- how to take a step, how to close it, &c. -- while the Iteratee describes a computation that computes an output and also tells us when to free the resource. Is that a correct interpretation? I find the material on Enumerator and Iterator to be vague (or at least not very concrete). I have seen code for a random access Iteratee/Enumerator pair, as well. In that case, the role of the Iteratee is to provide the "next step" to take -- one of forward , backward , close? -- _jsn From bugfact at gmail.com Sat Dec 20 06:00:20 2008 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Dec 20 05:52:49 2008 Subject: [Haskell-cafe] Re: [reactive] problem with unamb -- doesn't kill enough threads In-Reply-To: References: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> <494B6DF1.20704@gmail.com> Message-ID: I see. Of course, how silly of me, killThread is asynchronous, it only waits until the exception is raised in the receiving thread, but it does not wait until the thread is really killed. The documentation does not seem to mention this explicitly. Now, what would be the clean way to make sure all threads are indeed killed before the process quits? I tried to add another MVar that gets set after the thread handles uncatched exceptions (so something like bracket (forkIO a) (putMVar quit ()) return) and the code that calls killThread then does takeMVar quit, but this did not solve the problem. A yield didn't do it for me on Windows, I had a to put in a rather large threadDelay of 1/10th of a second... On Sat, Dec 20, 2008 at 6:25 AM, Conal Elliott wrote: > Oh -- I think the problem here was simply that the process itself exited > before all of the threads had a chance to get killed. When I add a short > sleep to the end of main, or even just a 'yield', I see that all threads > reported as killed. What clued me in was finally paying attention to the > observation that under ghci I get the new prompt *before* some of the kill > reports. > > - Conal > > > On Fri, Dec 19, 2008 at 11:17 AM, Conal Elliott wrote: > >> Peter, >> >> Thanks for digging. In your results below, I see only three out of four >> threads killed even in the best case. Each time, there is no report of the >> 'sleep 2' thread being killed. >> >> When I run your code on Linux (Ubuntu 8.10), everything looks great when >> run under ghci. If compiled, with and without -threaded and with and >> without +RTS -N2, I sometimes get four kill messages and sometimes fewer. >> In the latter case, I don't know if the other threads aren't getting killed >> or if they're killed but not reported. >> >> For example (removing messages other than "Killed"): >> >> conal@compy-doble:~/Haskell/Misc$ rm Threads.o ; ghc Threads.hs >> -threaded -o Threads && ./Threads +RTS -N2 >> Killed ThreadId 5 >> Killed ThreadId 4 >> >> conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 >> Killed ThreadId 5 >> Killed ThreadId 4 >> Killed ThreadId 7 >> Killed ThreadId 6 >> >> conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 >> Killed ThreadId 5 >> Killed ThreadId 7 >> Killed ThreadId 4 >> Killed ThreadId 6 >> >> conal@compy-doble:~/Haskell/Misc$ ./Threads +RTS -N2 >> Killed ThreadId 5 >> Killed ThreadId 4 >> >> conal@compy-doble:~/Haskell/Misc$ >> >> Simon -- does this behavior look like a GHC bug to you? >> >> - Conal >> >> >> On Fri, Dec 19, 2008 at 9:45 AM, Peter Verswyvelen wrote: >> >>> I played a bit the the bracket function that timeout uses, but got >>> strange results (both on Windows and OSX). >>> >>> Ugly code fragment follows: >>> >>> >>> -%<------------------------------------------------------------------------------------------------- >>> >>> import Prelude hiding (catch) >>> >>> import Control.Concurrent >>> import Control.Concurrent.MVar >>> import Control.Exception >>> import System.IO >>> import Data.Char >>> >>> withThread a b = bracket (forkIO a) kill (const b) >>> where >>> kill id = do >>> putStrLn ("Killing "++show id++"\n") >>> killThread id >>> putStrLn ("Killed "++show id++"\n") >>> >>> race a b = do >>> v <- newEmptyMVar >>> let t x = x >>= putMVar v >>> withThread (t a) $ withThread (t b) $ takeMVar v >>> >>> forkPut :: IO a -> MVar a -> IO ThreadId >>> forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler `catch` >>> bhandler) >>> where >>> uhandler (ErrorCall "Prelude.undefined") = return () >>> uhandler err = throw err >>> bhandler BlockedOnDeadMVar = return () >>> >>> sleep n = do >>> tid <- myThreadId >>> putStrLn ("Sleeping "++show n++" sec on "++show tid++"\n") >>> threadDelay (n*1000000) >>> putStrLn ("Slept "++show n++" sec on "++show tid++"\n") >>> >>> f = sleep 2 `race` sleep 3 >>> >>> g = f `race` sleep 1 >>> >>> main = do >>> hSetBuffering stdout LineBuffering >>> g >>> >>> >>> -%<------------------------------------------------------------------------------------------------- >>> >>> Here's the output when running with GHCI: >>> >>> C:\temp>runghc racetest >>> Sleeping 1 sec on ThreadId 26 >>> Sleeping 2 sec on ThreadId 27 >>> Sleeping 3 sec on ThreadId 28 >>> Slept 1 sec on ThreadId 26 >>> Killing ThreadId 26 >>> Killed ThreadId 26 >>> Killing ThreadId 25 >>> Killed ThreadId 25 >>> Killing ThreadId 28 >>> Killed ThreadId 28 >>> >>> Fine, all threads got killed. >>> >>> Here's the output from an EXE compiled with GHC -threaded, but run >>> without +RTS -N2 >>> >>> C:\temp> racetest >>> Sleeping 1 sec on ThreadId 5 >>> Sleeping 3 sec on ThreadId 7 >>> Sleeping 2 sec on ThreadId 6 >>> Slept 1 sec on ThreadId 5 >>> Killing ThreadId 5 >>> Killed ThreadId 5 >>> Killing ThreadId 4 >>> Killed ThreadId 4 >>> Killing ThreadId 7 >>> >>> So "Killed ThreadId 7" is not printed here. What did I do wrong? >>> >>> Here's the output from an EXE compiled with GHC -threaded, but run with >>> +RTS -N2 >>> >>> C:\temp> racetest +RTS -N2 >>> Sleeping 1 sec on ThreadId 5 >>> Sleeping 3 sec on ThreadId 7 >>> Sleeping 2 sec on ThreadId 6 >>> Slept 1 sec on ThreadId 5 >>> >>> Killing ThreadId 5 >>> Killed ThreadId 5 >>> Killing ThreadId 4 >>> Killed ThreadId 4 >>> Killing ThreadId 7 >>> Killed ThreadId 7 >>> >>> This works again. >>> >>> Is this intended behavior? >>> >>> Cheers, >>> Peter Verswyvelen >>> CTO - Anygma >>> >>> On Fri, Dec 19, 2008 at 10:48 AM, Simon Marlow wrote: >>> >>>> Sounds like you should use an exception handler so that when the parent >>>> dies it also kills its children. Be very careful with race conditions ;-) >>>> >>>> For a good example of how to do this sort of thing, see >>>> >>>> >>>> http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Timeout.html >>>> >>>> the docs are sadly missing the source links at the moment, I'm not sure >>>> why, but you can find the source in >>>> >>>> http://darcs.haskell.org/packages/base/System/Timeout.hs >>>> >>>> Cheers, >>>> Simon >>>> >>>> Conal Elliott wrote: >>>> >>>>> (I'm broadening the discussion to include haskell-cafe.) >>>>> >>>>> Andy -- What do you mean by "handling all thread forking locally"? >>>>> >>>>> - Conal >>>>> >>>>> On Thu, Dec 18, 2008 at 1:57 PM, Andy Gill >>>> andygill@ku.edu>> wrote: >>>>> >>>>> Conal, et. al, >>>>> >>>>> I was looking for exactly this about 6~9 months ago. I got the >>>>> suggestion to pose it as a challenge >>>>> to the community by Duncan Coutts. What you need is thread groups, >>>>> where for a ThreadId, you can send a signal >>>>> to all its children, even missing generations if needed. >>>>> I know of no way to fix this at the Haskell level without handling >>>>> all thread forking locally. >>>>> Perhaps a ICFP paper about the pending implementation :-) but I'm >>>>> not sure about the research content here. >>>>> >>>>> Again, there is something deep about values with lifetimes. >>>>> Andy Gill >>>>> >>>>> >>>>> On Dec 18, 2008, at 3:43 PM, Conal Elliott wrote: >>>>> >>>>> I realized in the shower this morning that there's a serious flaw >>>>>> in my unamb implementation as described in >>>>>> >>>>>> http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice. >>>>>> I'm looking for ideas for fixing the flaw. Here's the code for >>>>>> racing computations: >>>>>> >>>>>> race :: IO a -> IO a -> IO a >>>>>> a `race` b = do v <- newEmptyMVar >>>>>> ta <- forkPut a v >>>>>> tb <- forkPut b v >>>>>> x <- takeMVar v >>>>>> killThread ta >>>>>> killThread tb >>>>>> return x >>>>>> >>>>>> forkPut :: IO a -> MVar a -> IO ThreadId >>>>>> forkPut act v = forkIO ((act >>= putMVar v) `catch` uhandler >>>>>> `catch` bhandler) >>>>>> where >>>>>> uhandler (ErrorCall "Prelude.undefined") = return () >>>>>> uhandler err = throw err >>>>>> bhandler BlockedOnDeadMVar = return () >>>>>> >>>>>> The problem is that each of the threads ta and tb may have spawned >>>>>> other threads, directly or indirectly. When I kill them, they >>>>>> don't get a chance to kill their sub-threads. >>>>>> >>>>>> Perhaps I want some form of garbage collection of threads, perhaps >>>>>> akin to Henry Baker's paper "The Incremental Garbage Collection of >>>>>> Processes". As with memory GC, dropping one consumer would >>>>>> sometimes result is cascading de-allocations. That cascade is >>>>>> missing from my implementation. >>>>>> >>>>>> Or maybe there's a simple and dependable manual solution, >>>>>> enhancing the method above. >>>>>> >>>>>> Any ideas? >>>>>> >>>>>> - Conal >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Reactive mailing list >>>>>> Reactive@haskell.org >>>>>> http://www.haskell.org/mailman/listinfo/reactive >>>>>> >>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------ >>>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/5bb730f5/attachment.htm From tom.davie at gmail.com Sat Dec 20 06:14:45 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Sat Dec 20 06:07:17 2008 Subject: [Haskell-cafe] Re: [reactive] problem with unamb -- doesn't kill enough threads In-Reply-To: References: <2338D369-6CE2-4C01-888A-1B74A59E44F0@ku.edu> <494B6DF1.20704@gmail.com> Message-ID: On 20 Dec 2008, at 12:00, Peter Verswyvelen wrote: > I see. Of course, how silly of me, killThread is asynchronous, it > only waits until the exception is raised in the receiving thread, > but it does not wait until the thread is really killed. The > documentation does not seem to mention this explicitly. > > Now, what would be the clean way to make sure all threads are indeed > killed before the process quits? I tried to add another MVar that > gets set after the thread handles uncatched exceptions (so something > like bracket (forkIO a) (putMVar quit ()) return) and the code that > calls killThread then does takeMVar quit, but this did not solve > the problem. I'm not sure I understand what the "problem" is ? if the process has died, why do we want to kill threads? Bob From martijn at van.steenbergen.nl Sat Dec 20 06:34:09 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Dec 20 06:26:38 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> Message-ID: <494CD831.20600@van.steenbergen.nl> Hi Neil, This is awesome, thank you. :-) It found a 'use liftM', 'use on' and three eta-reduces in Yogurt. It seems like the line numbers could be a bit more accurate: ./Network/Yogurt/IO.hs:54:3: Use liftM Found: rec >>= return . (c :) Why not: liftM (c :) rec Where the code is: 50 -- Waits for input, but once the first character is read, waits 51 -- no longer than the specified number of ms before giving up. 52 hGetImpatientLine :: Handle -> Int -> IO String 53 hGetImpatientLine h patience = rec where 54 rec = do 55 c <- hGetChar h 56 if c == '\n' 57 then return [c] 58 else do 59 b <- hWaitForInput h patience 60 if b 61 then rec >>= return . (c:) 62 else return [c] I imagine it could have told me to look at line 61 right away. Thanks, Martijn. From hpacheco at gmail.com Sat Dec 20 06:42:30 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Sat Dec 20 06:34:59 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <7b92c2840812200221m1e6c8e7x87b521e307defd6@mail.gmail.com> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <7b92c2840812200221m1e6c8e7x87b521e307defd6@mail.gmail.com> Message-ID: <7b92c2840812200342t9a4a4d1mbb8aace8a5ae8568@mail.gmail.com> Hi again, I have run HLint against my libraries and found lots of suggestions, mainly excessive brackets. This is what I suggest from my experience: . a suggestion for a rule: dollar eta: f $ x -> f x. some parser errors I encountered: import Data.Generics hiding ((:*:)) type instance Rep Id x = x Cheers, hugo On Sat, Dec 20, 2008 at 10:21 AM, Hugo Pacheco wrote: > I noticed that you convert point-wise into point-free.Perhaps you could > add some point-free transformations to remove redundancy in certain cases. > Is that a goal of the library? > > Cheers, > hugo > > > On Sat, Dec 20, 2008 at 9:55 AM, Neil Mitchell wrote: > >> Hi, >> >> I am pleased to announce HLint, a tool for making suggestions to >> improve your Haskell code. Previously this tool was called Dr Haskell >> and depended on a working installation of Yhc - both of those have now >> changed. HLint requires GHC 6.10*, and to install simply type: >> >> cabal update && cabal install hlint >> >> If you haven't yet installed the cabal command, instructions are here: >> http://ghcmutterings.wordpress.com/2008/11/10/bootstrapping-cabal-install/ >> >> As an example of what HLint does, running "hlint darcs-2.1.2" over the >> latest stable release of darcs gives 385 suggestions, including: >> >> darcs-2.1.2\src\CommandLine.lhs:46:1: Use a string literal >> Found: >> [' ', '\t', '"', '%'] >> Why not: >> " \t\"%" >> >> darcs-2.1.2\src\CommandLine.lhs:49:1: Eta reduce >> Found: >> quotedArg ftable >> = between (char '"') (char '"') $ quoteContent ftable >> Why not: >> quotedArg = between (char '"') (char '"') . quoteContent >> >> darcs-2.1.2\src\CommandLine.lhs:94:1: Use concatMap >> Found: >> concat $ map escapeC s >> Why not: >> concatMap escapeC s >> >> To see all the hints in a nice interactive document visit >> http://www-users.cs.york.ac.uk/~ndm/hlint/hlint-report.htm >> (recommended if you are thinking of trying out hlint) >> >> All necessary links, including a manual, hackage links, bug tracker >> and source code can be found from the tool website: >> http://www-users.cs.york.ac.uk/~ndm/hlint/ >> >> Acknowledgements: Niklas Broberg and the haskell-src-exts package have >> both been very helpful. The darcs users mailing list gave many good >> suggestions which I've incorportated. >> >> Please direct any follow up conversations to haskell-cafe@ >> >> Thanks >> >> Neil >> >> * Why GHC 6.10? View patterns. >> _______________________________________________ >> Haskell mailing list >> Haskell@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell >> > > > > -- > www.di.uminho.pt/~hpacheco > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/68afee49/attachment.htm From niklas.broberg at gmail.com Sat Dec 20 07:42:13 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sat Dec 20 07:34:40 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <494CD831.20600@van.steenbergen.nl> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <494CD831.20600@van.steenbergen.nl> Message-ID: > It seems like the line numbers could be a bit more accurate: > > ./Network/Yogurt/IO.hs:54:3: Use liftM > Found: > rec >>= return . (c :) > Why not: > liftM (c :) rec > > Where the code is: > > 50 -- Waits for input, but once the first character is read, waits > 51 -- no longer than the specified number of ms before giving up. > 52 hGetImpatientLine :: Handle -> Int -> IO String > 53 hGetImpatientLine h patience = rec where > 54 rec = do > 55 c <- hGetChar h > 56 if c == '\n' > 57 then return [c] > 58 else do > 59 b <- hWaitForInput h patience > 60 if b > 61 then rec >>= return . (c:) > 62 else return [c] > > I imagine it could have told me to look at line 61 right away. You can blame HSE in this case, it only stores line numbers for certain constructs, and expressions are not among them. The closest predictable construct for this case is the RHS of the function definition, which is why you get line 54. This is something I hope to improve in HSE over time. Cheers, /Niklas From niklas.broberg at gmail.com Sat Dec 20 08:05:19 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sat Dec 20 07:57:47 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <7b92c2840812200342t9a4a4d1mbb8aace8a5ae8568@mail.gmail.com> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <7b92c2840812200221m1e6c8e7x87b521e307defd6@mail.gmail.com> <7b92c2840812200342t9a4a4d1mbb8aace8a5ae8568@mail.gmail.com> Message-ID: > . some parser errors I encountered: import Data.Generics hiding ((:*:)) > type instance Rep Id x = x The first is due to a bug in HSE which I've now fixed, thanks a lot for reporting! The second is parsed just fine by HSE so I don't know what's up there. Cheers, /Niklas From martijn at van.steenbergen.nl Sat Dec 20 08:38:10 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Dec 20 08:30:37 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <494CD831.20600@van.steenbergen.nl> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <494CD831.20600@van.steenbergen.nl> Message-ID: <494CF542.7070005@van.steenbergen.nl> Hi Neil, Another question: Darcs/Commands/Optimize.lhs:110:1: Use isPrefixOf, and then remove the (==) test Found: take 4 (just_name pinfo) == "TAG " Why not: (4 == length "TAG ") && ("TAG " `isPrefixOf` just_name pinfo) I assume the (==) referred to in the name of the fix is the one in the suggestion. Why doesn't the suggestion come with the check removed? I.e.: Why not: ("TAG " `isPrefixOf` just_name pinfo) Thanks, Martijn. From gwern0 at gmail.com Sat Dec 20 08:59:50 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Dec 20 08:52:20 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Sat, Dec 20, 2008 at 4:55 AM, Neil Mitchell wrote: > Hi, > > I am pleased to announce HLint, a tool for making suggestions to > improve your Haskell code. Previously this tool was called Dr Haskell > and depended on a working installation of Yhc - both of those have now > changed. HLint requires GHC 6.10*, and to install simply type: > > cabal update && cabal install hlint > > If you haven't yet installed the cabal command, instructions are here: > http://ghcmutterings.wordpress.com/2008/11/10/bootstrapping-cabal-install/ > > As an example of what HLint does, running "hlint darcs-2.1.2" over the > latest stable release of darcs gives 385 suggestions, including: > > darcs-2.1.2\src\CommandLine.lhs:46:1: Use a string literal > Found: > [' ', '\t', '"', '%'] > Why not: > " \t\"%" > > darcs-2.1.2\src\CommandLine.lhs:49:1: Eta reduce > Found: > quotedArg ftable > = between (char '"') (char '"') $ quoteContent ftable > Why not: > quotedArg = between (char '"') (char '"') . quoteContent > > darcs-2.1.2\src\CommandLine.lhs:94:1: Use concatMap > Found: > concat $ map escapeC s > Why not: > concatMap escapeC s > > To see all the hints in a nice interactive document visit > http://www-users.cs.york.ac.uk/~ndm/hlint/hlint-report.htm > (recommended if you are thinking of trying out hlint) > > All necessary links, including a manual, hackage links, bug tracker > and source code can be found from the tool website: > http://www-users.cs.york.ac.uk/~ndm/hlint/ > > Acknowledgements: Niklas Broberg and the haskell-src-exts package have > both been very helpful. The darcs users mailing list gave many good > suggestions which I've incorportated. > > Please direct any follow up conversations to haskell-cafe@ > > Thanks > > Neil > > * Why GHC 6.10? View patterns. Hi, Neil. Thanks for the tool; it found some worthwhile changes in my projects. But a few points: 1) How does one actually use the CLI tool? You didn't say. It *seems* that one just feeds it a list of random filepaths, so on Mueval, say, the command would be 'hlint main.hs Mueval/*.hs' (and not, say, 'hlint mueval.cabal'). But I'm not actually sure. 2) I think I found a parsing bug. One line in Mueval/Interpreter.hs runs: > fmap (take n exceptionMsg ++) $ render' (n-length exceptionMsg) s which gives the error: > Mueval/Interpreter.hs:145:59: Parse failure, Parse error > No relevant suggestions Adding spaces between 'n' and 'length', so it reads: > fmap (take n exceptionMsg ++) $ render' (n - length exceptionMsg) s lets hlint parse and suggest for it. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklM+kwACgkQvpDo5Pfl1oKDhwCfRgQutbvr9QbKvbLJlbhdla2Z absAniWC+ksXHhfbunsdOsnmG69lppFZ =X9uv -----END PGP SIGNATURE----- From bulat.ziganshin at gmail.com Sat Dec 20 09:28:00 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Dec 20 09:20:41 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <494CF542.7070005@van.steenbergen.nl> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <494CD831.20600@van.steenbergen.nl> <494CF542.7070005@van.steenbergen.nl> Message-ID: <223051561.20081220172800@gmail.com> Hello Martijn, Saturday, December 20, 2008, 4:38:10 PM, you wrote: > Why not: > (4 == length "TAG ") && ("TAG " `isPrefixOf` just_name pinfo) > I assume the (==) referred to in the name of the fix is the one in the > suggestion. Why doesn't the suggestion come with the check removed? I.e.: due to Turing computability problem, i believe :) although Neil may try to run it in separate thread :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From felipe.lessa at gmail.com Sat Dec 20 09:47:22 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Dec 20 09:39:50 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <223051561.20081220172800@gmail.com> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <494CD831.20600@van.steenbergen.nl> <494CF542.7070005@van.steenbergen.nl> <223051561.20081220172800@gmail.com> Message-ID: On Sat, Dec 20, 2008 at 12:28 PM, Bulat Ziganshin wrote: > Saturday, December 20, 2008, 4:38:10 PM, you wrote: >> Why not: >> (4 == length "TAG ") && ("TAG " `isPrefixOf` just_name pinfo) > >> I assume the (==) referred to in the name of the fix is the one in the >> suggestion. Why doesn't the suggestion come with the check removed? I.e.: > > due to Turing computability problem, i believe :) although Neil may > try to run it in separate thread :) In the general case it is, but most of the time we use a constant as first argument to isPrefixOf and as such its length may be calculated in finite (and very small) time. This is a special case worth taking care of, I think. -- Felipe. From ndmitchell at gmail.com Sat Dec 20 10:06:30 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Dec 20 09:58:58 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <7b92c2840812200221m1e6c8e7x87b521e307defd6@mail.gmail.com> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <7b92c2840812200221m1e6c8e7x87b521e307defd6@mail.gmail.com> Message-ID: <404396ef0812200706x68fdb493j2ca10d89a33f9128@mail.gmail.com> Hi > I noticed that you convert point-wise into point-free. > Perhaps you could add some point-free transformations to remove redundancy > in certain cases. > Is that a goal of the library? It does some transformations of th at nature, but the idea isn't to remove redundancy, its to make the code clearer. Do you have any suggestions for things it could easily do to remove redundancy? It already does a few relating to if expressions. > a suggestion for a rule: dollar eta: f $ x -> f x That can easily be added. > Why not: > ("TAG " `isPrefixOf` just_name pinfo) That's an open bug: http://code.google.com/p/ndmitchell/issues/detail?id=109 In general, most of the hints are "replace this with this" - evaluating the new bit (even to remove easy constants) is beyond it for the moment. Some people theorised it might be too hard, non-terminating, or incorrect. As it happens this rule only fires when "TAG " is either a string literal or a list literal, and when the number is a constant, so its always safe and the guard could always be eliminated. > 1) How does one actually use the CLI tool? You didn't say. It *seems* > that one just feeds it a list of random filepaths, so on Mueval, say, > the command would be 'hlint main.hs Mueval/*.hs' (and not, say, 'hlint > mueval.cabal'). But I'm not actually sure. The filenames are either filenames, or directories which are recursively searched, i.e cd mueval && hlint . is probably sufficient. I should document it more clearly in the manual. Thanks Neil From tphyahoo at gmail.com Sat Dec 20 10:15:36 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Dec 20 10:08:04 2008 Subject: [Haskell-cafe] I hate constructing strings with ++ Message-ID: <910ddf450812200715y6b79541are87095b6256acbcd@mail.gmail.com> I hate constructing strings with ++. Especially icky when you start dealing with escape characters and stuff. cabal install HStringTemplateHelpers ..... import Text.StringTemplate.Helpers putStrLn $ render1 [("name",name)] "Why, hello, $name$" just thinkin out loud :) (originally at http://www.reddit.com/r/programming/comments/7khkd/the_fun_of_programming_a_collection_of_haskell/p6iP) From tphyahoo at gmail.com Sat Dec 20 10:16:38 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Dec 20 10:09:05 2008 Subject: [Haskell-cafe] Re: I hate constructing strings with ++ In-Reply-To: <910ddf450812200715y6b79541are87095b6256acbcd@mail.gmail.com> References: <910ddf450812200715y6b79541are87095b6256acbcd@mail.gmail.com> Message-ID: <910ddf450812200716vf5ac765qe521d0bf38dcef10@mail.gmail.com> Correction: > name = "Bill" > import Text.StringTemplate.Helpers > putStrLn $ render1 [("name",name)] "Why, hello, $name$" 2008/12/20 Thomas Hartman : > I hate constructing strings with ++. Especially icky when you start > dealing with escape character and stuff. > > cabal install HStringTemplateHelpers > > ..... > > import Text.StringTemplate.Helpers > putStrLn $ render1 [("name",name)] "Why, hello, $name$" > > just thinkin out loud :) > > (originally at http://www.reddit.com/r/programming/comments/7khkd/the_fun_of_programming_a_collection_of_haskell/p6iP) > From hpacheco at gmail.com Sat Dec 20 10:30:45 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Sat Dec 20 10:23:12 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: <404396ef0812200706x68fdb493j2ca10d89a33f9128@mail.gmail.com> References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <7b92c2840812200221m1e6c8e7x87b521e307defd6@mail.gmail.com> <404396ef0812200706x68fdb493j2ca10d89a33f9128@mail.gmail.com> Message-ID: <7b92c2840812200730v3f6382e7l684d4c5ec5b04ac3@mail.gmail.com> On Sat, Dec 20, 2008 at 3:06 PM, Neil Mitchell wrote: > Hi > > > I noticed that you convert point-wise into point-free. > > Perhaps you could add some point-free transformations to remove > redundancy > > in certain cases. > > Is that a goal of the library? > > It does some transformations of th at nature, but the idea isn't to > remove redundancy, its to make the code clearer. Do you have any > suggestions for things it could easily do to remove redundancy? There are many simple ones, such as: f . id -> f filter true -> id map id -> id ... etc > It > already does a few relating to if expressions. > Yes, like map f . map g -> map (f . g) You can find more in Transformation of Structure-Shy Programs - Applied to XPath Queries and Strategic Functions, page 4. > > > a suggestion for a rule: dollar eta: f $ x -> f x > > That can easily be added. > > > Why not: > > ("TAG " `isPrefixOf` just_name pinfo) > > That's an open bug: > http://code.google.com/p/ndmitchell/issues/detail?id=109 > > In general, most of the hints are "replace this with this" - > evaluating the new bit (even to remove easy constants) is beyond it > for the moment. Some people theorised it might be too hard, > non-terminating, or incorrect. As it happens this rule only fires when > "TAG " is either a string literal or a list literal, and when the > number is a constant, so its always safe and the guard could always be > eliminated. > > > 1) How does one actually use the CLI tool? You didn't say. It *seems* > > that one just feeds it a list of random filepaths, so on Mueval, say, > > the command would be 'hlint main.hs Mueval/*.hs' (and not, say, 'hlint > > mueval.cabal'). But I'm not actually sure. > > The filenames are either filenames, or directories which are > recursively searched, i.e cd mueval && hlint . is probably sufficient. > I should document it more clearly in the manual. > > Thanks > > Neil > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/6c8749c5/attachment.htm From jason.dusek at gmail.com Sat Dec 20 10:33:40 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat Dec 20 10:26:08 2008 Subject: [Haskell-cafe] "non-functions like unsafePerformIO are not technically part of the haskell language!" Message-ID: <42784f260812200733n27def7e4l114f13f1b7d86a7b@mail.gmail.com> From an old thread: > non-functions like unsafePerformIO are not technically part > of the haskell language! How is this true, exactly? -- _jsn |...an old thread.| http://www.nabble.com/Re%3A-Re%3A-Parsers-are-monadic--p11390440.html From lennart at augustsson.net Sat Dec 20 10:43:28 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Sat Dec 20 10:35:55 2008 Subject: [Haskell-cafe] "non-functions like unsafePerformIO are not technically part of the haskell language!" In-Reply-To: <42784f260812200733n27def7e4l114f13f1b7d86a7b@mail.gmail.com> References: <42784f260812200733n27def7e4l114f13f1b7d86a7b@mail.gmail.com> Message-ID: The current official Haskell standard is Haskell-98. There is no unsafePerformIO in there. On Sat, Dec 20, 2008 at 3:33 PM, Jason Dusek wrote: > From an old thread: > >> non-functions like unsafePerformIO are not technically part >> of the haskell language! > > How is this true, exactly? > > -- > _jsn > > > |...an old thread.| > http://www.nabble.com/Re%3A-Re%3A-Parsers-are-monadic--p11390440.html > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lrpalmer at gmail.com Sat Dec 20 10:43:28 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Dec 20 10:36:07 2008 Subject: [Haskell-cafe] "non-functions like unsafePerformIO are not technically part of the haskell language!" In-Reply-To: <42784f260812200733n27def7e4l114f13f1b7d86a7b@mail.gmail.com> References: <42784f260812200733n27def7e4l114f13f1b7d86a7b@mail.gmail.com> Message-ID: <7ca3f0160812200743g36d2b162j9270373cad8f6ce5@mail.gmail.com> On Sat, Dec 20, 2008 at 8:33 AM, Jason Dusek wrote: > From an old thread: > > > non-functions like unsafePerformIO are not technically part > > of the haskell language! > > How is this true, exactly? The Haskell 98 report (http://www.haskell.org/onlinereport/), according to my cursory scan, makes no mention of unsafePerformIO. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/0cffbb98/attachment-0001.htm From niklas.broberg at gmail.com Sat Dec 20 10:47:07 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sat Dec 20 10:39:33 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> Message-ID: Hi Gwern, > 2) I think I found a parsing bug. One line in Mueval/Interpreter.hs runs: > >> fmap (take n exceptionMsg ++) $ render' (n-length exceptionMsg) s > > which gives the error: > >> Mueval/Interpreter.hs:145:59: Parse failure, Parse error >> No relevant suggestions > > Adding spaces between 'n' and 'length', so it reads: > >> fmap (take n exceptionMsg ++) $ render' (n - length exceptionMsg) s > > lets hlint parse and suggest for it. This is clearly a HSE bug, and seeing your example I know exactly the oversight I've made. Unfortunately I don't see immediately how to fix it so I'll have to think on it for a while. Thanks for reporting it! Cheers, /Niklas From jefferson.r.heard at gmail.com Sat Dec 20 10:59:42 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sat Dec 20 10:52:08 2008 Subject: [Haskell-cafe] Beginner's TH question Message-ID: <4165d3a70812200759v157714daice15f60644c04427@mail.gmail.com> Two things... can I add fields to records using Template Haskell, like: data T = T { $fields, myfield :: Field, ... } I assume the answer there is no, and then what's wrong with this? I get: Illegal instance declaration for `UIState t' (All instance types must be of the form (T a1 ... an) where a1 ... an are type *variables*, and each type variable appears at most once in the instance head. Use -XFlexibleInstances if you want to disable this.) In the instance declaration for `UIState t' In the expression: [d| instance UIState t where { setSizeY v a = setSizeY v . uist $ a setSizeX v a = setSizeX v . uist $ a setDrawing v a = setDrawing v . uist $ a setKey v a = setKey v . uist $ a .... } |] In the definition of `deriveUIState': deriveUIState uist t = [d| instance UIState t where { setSizeY v a = setSizeY v . uist $ a setSizeX v a = setSizeX v . uist $ a setDrawing v a = setDrawing v . uist $ a .... } |] in this module: -# LANGUAGE TemplateHaskell #-} module Graphics.Rendering.Thingie.TH where import Language.Haskell.TH import Graphics.Rendering.Thingie.UIState import qualified Graphics.Rendering.Thingie.BasicUIState as S deriveUIState uist t = [d| instance UIState t where mousePosition a = S.mousePosition . uist $ a mouseLeftButtonDown a = S.mouseLeftButtonDown . uist $ a mouseRightButtonDown a = S.mouseRightButtonDown . uist $ a mouseMiddleButtonDown a = S.mouseMiddleButtonDown . uist $ a mouseLeftButtonClicked a = S.mouseLeftButtonClicked . uist $ a mouseRightButtonClicked a = S.mouseRightButtonClicked . uist $ a mouseMiddleButtonClicked a = S.mouseMiddleButtonClicked . uist $ a mouseWheel a = S.mouseWheel . uist $ a keyCtrl a = S.keyCtrl . uist $ a keyShift a = S.keyShift . uist $ a keyAlt a = S.keyAlt . uist $ a key a = S.key . uist $ a drawing a = S.drawing . uist $ a sizeX a = S.sizeX . uist $ a sizeY a = S.sizeY . uist $ a setMousePosition v a = setMousePosition v . uist $ a setMouseLeftButtonDown v a = setMouseLeftButtonDown v . uist $ a setMouseRightButtonDown v a = setMouseRightButtonDown v . uist $ a setMouseMiddleButtonDown v a = setMouseMiddleButtonDown v . uist $ a setMouseLeftButtonClicked v a = setMouseLeftButtonClicked v . uist $ a setMouseRightButtonClicked v a = setMouseRightButtonClicked v . uist $ a setMouseMiddleButtonClicked v a = setMouseMiddleButtonClicked v . uist $ a setMouseWheel v a = setMouseWheel v . uist $ a setKeyCtrl v a = setKeyCtrl v . uist $ a setKeyShift v a = setKeyShift v . uist $ a setKeyAlt v a = setKeyAlt v . uist $ a setKey v a = setKey v . uist $ a setDrawing v a = setDrawing v . uist $ a setSizeX v a = setSizeX v . uist $ a setSizeY v a = setSizeY v . uist $ a |] From niklas.broberg at gmail.com Sat Dec 20 11:18:23 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sat Dec 20 11:10:51 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: Message-ID: > All of these get one thing right that the current and most of the proposed > Haskell logos do not: they don't make any reference to the syntax of the > language itself. Doing so seems to miss the point of a logo: it's supposed > to appeal visually, rather than semantically. So I'd like to see some > submissions that don't use lambdas. Interesting how perceptions can vary. Of all the logos you linked to, only the Python logo is anywhere near visually appealing to me, and even that seems a bit much. Less is more (which incidentally is a concept that also relates very well to Haskell's powerful abstraction mechanisms), and that is doubly so in a logo. I want a logo that could be adapted to be used in a lot of different situations, from t-shirts to favicons to mascots, sometimes even with slightly different connotations and references. I want a logo that I could draw fairly accurately on a piece of paper in 10 seconds. And as such, I vastly prefer many of those suggested on the wiki to all those you've presented here. I think all of those shown here get all the things I've mentioned wrong. And the fact that others do it this way isn't really an argument either. Since when has Haskell ever does something just because everyone else does it that way? :-) Cheers, /Niklas From niklas.broberg at gmail.com Sat Dec 20 11:19:30 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Sat Dec 20 11:11:57 2008 Subject: [Haskell-cafe] Re: Logos of Other Languages In-Reply-To: <87tz8ztl31.fsf@justinbogner.com> References: <87tz8ztl31.fsf@justinbogner.com> Message-ID: > An homage to syntax at least gives an easily recognizable icon, far more > iconic than a camel or a grid of colours, and I would consider several > of the lambda based ideas on the wiki simple, elegant and visually > appealing. Exactly! Cheers, /Niklas From duncan.coutts at worc.ox.ac.uk Sat Dec 20 11:22:53 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Dec 20 11:15:21 2008 Subject: [Haskell-cafe] "non-functions like unsafePerformIO are not technically part of the haskell language!" In-Reply-To: References: <42784f260812200733n27def7e4l114f13f1b7d86a7b@mail.gmail.com> Message-ID: <1229790173.10115.813.camel@localhost> On Sat, 2008-12-20 at 15:43 +0000, Lennart Augustsson wrote: > The current official Haskell standard is Haskell-98. There is no > unsafePerformIO in there. It's in the FFI spec which is an official addendum to Haskell 98. ;-) Duncan From lennart at augustsson.net Sat Dec 20 11:42:09 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Sat Dec 20 11:34:36 2008 Subject: [Haskell-cafe] "non-functions like unsafePerformIO are not technically part of the haskell language!" In-Reply-To: <1229790173.10115.813.camel@localhost> References: <42784f260812200733n27def7e4l114f13f1b7d86a7b@mail.gmail.com> <1229790173.10115.813.camel@localhost> Message-ID: Bah! I had nothing to do with that. ;) On Sat, Dec 20, 2008 at 4:22 PM, Duncan Coutts wrote: > On Sat, 2008-12-20 at 15:43 +0000, Lennart Augustsson wrote: >> The current official Haskell standard is Haskell-98. There is no >> unsafePerformIO in there. > > It's in the FFI spec which is an official addendum to Haskell 98. > ;-) > > Duncan > From bulat.ziganshin at gmail.com Sat Dec 20 11:49:05 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Dec 20 11:41:56 2008 Subject: [Haskell-cafe] Beginner's TH question In-Reply-To: <4165d3a70812200759v157714daice15f60644c04427@mail.gmail.com> References: <4165d3a70812200759v157714daice15f60644c04427@mail.gmail.com> Message-ID: <596443149.20081220194905@gmail.com> Hello Jeff, Saturday, December 20, 2008, 6:59:42 PM, you wrote: my experience tells that you should insert whole language sentences, like $(add_fields [d| data T = T { myfield :: Field, ... } ] ) where original declaration passed as a parameter > Two things... can I add fields to records using Template Haskell, like: > data T = T { $fields, myfield :: Field, ... } > I assume the answer there is no, and then what's wrong with this? I get: > Illegal instance declaration for `UIState t' > (All instance types must be of the form (T a1 ... an) > where a1 ... an are type *variables*, > and each type variable appears at most once in the instance head. > Use -XFlexibleInstances if you want to disable this.) > In the instance declaration for `UIState t' > In the expression: > [d| > instance UIState t where > { setSizeY v a = setSizeY v . uist $ a > setSizeX v a = setSizeX v . uist $ a > setDrawing v a = setDrawing v . uist $ a > setKey v a = setKey v . uist $ a > .... } |] > In the definition of `deriveUIState': > deriveUIState uist t > = [d| > instance UIState t where > { setSizeY v a = setSizeY v . uist $ a > setSizeX v a = setSizeX v . uist $ a > setDrawing v a = setDrawing v . uist $ a > .... } |] > in this module: > -# LANGUAGE TemplateHaskell #-} > module Graphics.Rendering.Thingie.TH where > import Language.Haskell.TH > import Graphics.Rendering.Thingie.UIState > import qualified Graphics.Rendering.Thingie.BasicUIState as S > deriveUIState uist t = > [d| instance UIState t where > mousePosition a = S.mousePosition . uist $ a > mouseLeftButtonDown a = S.mouseLeftButtonDown . uist $ a > mouseRightButtonDown a = S.mouseRightButtonDown . uist $ a > mouseMiddleButtonDown a = S.mouseMiddleButtonDown . uist $ a > mouseLeftButtonClicked a = S.mouseLeftButtonClicked . uist $ a > mouseRightButtonClicked a = S.mouseRightButtonClicked . uist $ a > mouseMiddleButtonClicked a = S.mouseMiddleButtonClicked . uist $ a > mouseWheel a = S.mouseWheel . uist $ a > keyCtrl a = S.keyCtrl . uist $ a > keyShift a = S.keyShift . uist $ a > keyAlt a = S.keyAlt . uist $ a > key a = S.key . uist $ a > drawing a = S.drawing . uist $ a > sizeX a = S.sizeX . uist $ a > sizeY a = S.sizeY . uist $ a > setMousePosition v a = setMousePosition v . uist $ a > setMouseLeftButtonDown v a = setMouseLeftButtonDown v . uist $ a > setMouseRightButtonDown v a = setMouseRightButtonDown v . uist $ a > setMouseMiddleButtonDown v a = setMouseMiddleButtonDown v . uist $ a > setMouseLeftButtonClicked v a = setMouseLeftButtonClicked > v . uist $ a > setMouseRightButtonClicked v a = > setMouseRightButtonClicked v . uist $ a > setMouseMiddleButtonClicked v a = > setMouseMiddleButtonClicked v . uist $ a > setMouseWheel v a = setMouseWheel v . uist $ a > setKeyCtrl v a = setKeyCtrl v . uist $ a > setKeyShift v a = setKeyShift v . uist $ a > setKeyAlt v a = setKeyAlt v . uist $ a > setKey v a = setKey v . uist $ a > setDrawing v a = setDrawing v . uist $ a > setSizeX v a = setSizeX v . uist $ a > setSizeY v a = setSizeY v . uist $ a > |] > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From johan.tibell at gmail.com Sat Dec 20 12:31:59 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Sat Dec 20 12:24:28 2008 Subject: [Haskell-cafe] I hate constructing strings with ++ In-Reply-To: <910ddf450812200715y6b79541are87095b6256acbcd@mail.gmail.com> References: <910ddf450812200715y6b79541are87095b6256acbcd@mail.gmail.com> Message-ID: <90889fe70812200931y796f92b9n67ebdc9a8411ba74@mail.gmail.com> On Sat, Dec 20, 2008 at 4:15 PM, Thomas Hartman wrote: > I hate constructing strings with ++. Especially icky when you start > dealing with escape characters and stuff. > > cabal install HStringTemplateHelpers > > ..... > > import Text.StringTemplate.Helpers > putStrLn $ render1 [("name",name)] "Why, hello, $name$" I once wrote a simple library for "classical" $-substitution. I plan to upgrade it to use Data.Text (efficient bytestring like representation for Unicode strings) whenever that's release. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/template Cheers, Johan From miguelimo38 at yandex.ru Sat Dec 20 12:38:40 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat Dec 20 12:31:10 2008 Subject: [Haskell-cafe] Beginner's TH question In-Reply-To: <4165d3a70812200759v157714daice15f60644c04427@mail.gmail.com> References: <4165d3a70812200759v157714daice15f60644c04427@mail.gmail.com> Message-ID: <25D7CCE5-F768-4ADD-8A2B-F56B9A217470@yandex.ru> Seems like GHC had already told you what's wrong. Instance declarations like "instance UIState t" are illegal without FlexibleInstances language feature enabled. Also, I don't quite understand, what you're trying to achieve; argument "t" and the letter "t" in the TH body are two different beasts, so your "derive..." would be of no use. May be, you want something like this: {-# LANGUAGE TemplateHaskell #-} module TH where import Language.Haskell.TH import Language.Haskell.TH.Syntax class C a where c :: a -> a deriveC t = do decs <- [d| c x = x |] tp <- t return [InstanceD [] (AppT (ConT ''C) tp) decs] {-# LANGUAGE TemplateHaskell #-} module THTest where import TH $(deriveC [t| Int |]) *THTest> c (1 :: Int) 1 On 20 Dec 2008, at 18:59, Jeff Heard wrote: > Two things... can I add fields to records using Template Haskell, > like: > > data T = T { $fields, myfield :: Field, ... } > > I assume the answer there is no, and then what's wrong with this? I > get: > > Illegal instance declaration for `UIState t' > (All instance types must be of the form (T a1 ... an) > where a1 ... an are type *variables*, > and each type variable appears at most once in the instance > head. > Use -XFlexibleInstances if you want to disable this.) > In the instance declaration for `UIState t' > In the expression: > [d| > instance UIState t where > { setSizeY v a = setSizeY v . uist $ a > setSizeX v a = setSizeX v . uist $ a > setDrawing v a = setDrawing v . uist $ a > setKey v a = setKey v . uist $ a > .... } |] > In the definition of `deriveUIState': > deriveUIState uist t > = [d| > instance UIState t where > { setSizeY v a = setSizeY v . uist > $ a > setSizeX v a = setSizeX v . uist > $ a > setDrawing v a = setDrawing v . > uist $ a > .... } |] > > in this module: > > -# LANGUAGE TemplateHaskell #-} > module Graphics.Rendering.Thingie.TH where > > import Language.Haskell.TH > import Graphics.Rendering.Thingie.UIState > import qualified Graphics.Rendering.Thingie.BasicUIState as S > > > deriveUIState uist t = > [d| instance UIState t where > mousePosition a = S.mousePosition . uist $ a > mouseLeftButtonDown a = S.mouseLeftButtonDown . uist $ a > mouseRightButtonDown a = S.mouseRightButtonDown . uist $ a > mouseMiddleButtonDown a = S.mouseMiddleButtonDown . uist > $ a > mouseLeftButtonClicked a = S.mouseLeftButtonClicked . > uist $ a > mouseRightButtonClicked a = S.mouseRightButtonClicked . > uist $ a > mouseMiddleButtonClicked a = S.mouseMiddleButtonClicked . > uist $ a > mouseWheel a = S.mouseWheel . uist $ a > keyCtrl a = S.keyCtrl . uist $ a > keyShift a = S.keyShift . uist $ a > keyAlt a = S.keyAlt . uist $ a > key a = S.key . uist $ a > drawing a = S.drawing . uist $ a > sizeX a = S.sizeX . uist $ a > sizeY a = S.sizeY . uist $ a > setMousePosition v a = setMousePosition v . uist $ a > setMouseLeftButtonDown v a = setMouseLeftButtonDown v . > uist $ a > setMouseRightButtonDown v a = setMouseRightButtonDown v . > uist $ a > setMouseMiddleButtonDown v a = setMouseMiddleButtonDown > v . uist $ a > setMouseLeftButtonClicked v a = setMouseLeftButtonClicked > v . uist $ a > setMouseRightButtonClicked v a = > setMouseRightButtonClicked v . uist $ a > setMouseMiddleButtonClicked v a = > setMouseMiddleButtonClicked v . uist $ a > setMouseWheel v a = setMouseWheel v . uist $ a > setKeyCtrl v a = setKeyCtrl v . uist $ a > setKeyShift v a = setKeyShift v . uist $ a > setKeyAlt v a = setKeyAlt v . uist $ a > setKey v a = setKey v . uist $ a > setDrawing v a = setDrawing v . uist $ a > setSizeX v a = setSizeX v . uist $ a > setSizeY v a = setSizeY v . uist $ a > |] > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From briqueabraque at yahoo.com Sat Dec 20 13:06:13 2008 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sat Dec 20 12:58:49 2008 Subject: [Haskell-cafe] Re: Detecting system endianness In-Reply-To: <494C90FE.7010002@freegeek.org> References: <2f9b2d30812180433l492173b3pab5dd1b51debe56d@mail.gmail.com> <2f9b2d30812180440p586e7d00mc24a26577dadbbf9@mail.gmail.com> <200812181403.40459.holgersiegel74@yahoo.de> <494B168C.8020900@freegeek.org> <494C90FE.7010002@freegeek.org> Message-ID: >> But why would you want that? I understand the only >> situation when talking about number of bytes >> makes sense is when you are using Foreign and >> Ptr. (...) > Because I'm using both Ptr and Foreign? ;) > > See my recent announcement for bytestring-trie. One of the optimizations > I'm working on is to read off a full natural word at a time, (...) I see, you mean the size of a machine word, not of Data.Word. From gwern0 at gmail.com Sat Dec 20 13:10:44 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Dec 20 13:03:14 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> <404396ef0812200734w5aae1463t11531d6bac6fc0a4@mail.gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 So has anyone figured out how to integrate hlint with ghci? I've tried several approaches. Using hlint as a preprocessor ( http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#pre-processor ) doesn't work because the pre-processor needs to take 3 args. Even if one writes a wrapper shell script along the lines of 'cp $2 $3 && hlint $2', this still won't work. It apparently breaks when you load a file which requires another file. I am not sure why. I then thought to redefine :load and :reload in ghci; this would work very well with Emacs and Yi, since they tell ghci to :load and :reload buffers. Turns out, you're not allowed to overwrite :load and :reload. You can do :def reload whatever to your heart's content, but the new version never takes. (Not even if defined in .ghci.) Alright. A :hlint would probably be enough. I can always edit Yi/Emacs to follow a :reload/:load with a :hlint, after all. And aren't there shell command primitives already? So I set out, and I realize: I can't simply settle for some version of :! "hlint .", because the working directory rarely changes - if one opens ghci in ~/, and loads a file elsewhere, :pwd reveals one to still be in ~/. And a 'hlint .' could take a very long time indeed in ~/. Well, alright. I just need the file name of the module I'm working with. Surely there is an easy way to do that. And indeed, :show modules gives me what I'm looking for: *Recorder Control.Monad Data.Char Data.List> :show modules Util ( Util.hs, interpreted ) Recorder ( Recorder.hs, interpreted ) Game ( Game.hs, interpreted ) Monadius ( Monadius.hs, interpreted ) Demo ( Demo.hs, interpreted ) Well, sort of. Ok, we can parse that. Let's assume a variable x holds the output of :show modules as a String. We call lines on it, then map words on it, do a !! 2 on it, and we get ["Util.hs,", "Recorder.hs,", "Game.hs,", "Monadius.hs,", "Demo.hs,"]. Chuck in a map (filter (\= ',')), and we get a good list. We can turn the list into a string suitable for hlint with a quick unwords. So our long sought after command becomes ':def hoogle (\_ -> return $ ":! " ++ (unwords $ map (filter (\= ',')) $ (map words $ lines x) !! 2))'. But wait, how do we get 'x'? How do we call :show modules inside a Haskell expression? I have carefully looked over http://haskell.org/haskellwiki/GHC/GHCi#Using_GHCi and http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-commands.html and my conclusion is that you can't. You can't do a let x = :show modules, there is no function which will take ":show modules", and so on. :functions can accept Haskell output, but it's a one-way barrier. It's no good writing Haskell functions which need information from the :functions. Which all leaves me where I started - no ghci integration with hlint. Any ideas? - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklNNSIACgkQvpDo5Pfl1oJwWgCfZJ7nwkHfsZymIRass0ewmhFE en4AnjmQam3V8Go6pGoLTRsp5zZEzAms =nmJm -----END PGP SIGNATURE----- From slehuitouze at telisma.com Sat Dec 20 14:43:54 2008 From: slehuitouze at telisma.com (Serge LE HUITOUZE) Date: Sat Dec 20 14:36:22 2008 Subject: [Haskell-cafe] Trouble with FFI on Windows2000... Message-ID: Hi there! I'm trying to FFI-bind a MS Visual dll (under Windows2000) to a Haskell program. I have this little C(++) dll: ******* FILE inc.h: START ******* extern "C" { int pten(int i); } ******* FILE inc.h: END ******* ******* FILE inc.cpp: START ******* #include "inc.h" int pten(int i) { return i+10; } ******* FILE inc.cpp: END ******* ******* FILE cproj1.def: START ******* LIBRARY cproj1 EXPORTS pten ******* FILE cproj1.def: END ******* And this little Haskell program: ******* FILE testFFI_2.hs: START ******* {-# LANGUAGE ForeignFunctionInterface #-} module Main where import Foreign.C -- get the C types foreign import ccall unsafe "pten" c_pten :: CInt -> CInt plus10 :: Int -> Int plus10 i = fromIntegral (c_pten (fromIntegral i)) main = print (map plus10 [1..10]) ******* FILE testFFI_2.lhs: END ******* Using information found at paragraph 1.4.3.4 of http://www.haskell.org/haskellwiki/GHC:FAQ#GHC_on_Windows I do the following: > dlltool -d cproj1.def -l libcproj1.a > ghc --make testFFI_2.hs -optl-lcproj1 -optl-L. This seems fine, since it produces a "testFFI_2.exe". However, executing it, I get a MSWindows error box with a message that looks like (approximate translation): "DLL (null) not found on specified path" At first, I didn't have the "LIBRARY" directive in the ".def" file, so I thought that was the reason for the "(null)" appearing in the message. But adding said directive didn't change anything... [I've checked that my MSVisual dll was in current dir, and that this dir was in the search paths showed in the error box] Can anyone enlighten me? Thanks in advance. --Serge From wagner.andrew at gmail.com Sat Dec 20 15:37:50 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Sat Dec 20 15:30:18 2008 Subject: [Haskell-cafe] Pattern combinators Message-ID: All, Wadler posted a blog entry the other day about a paper on pattern-matching in Haskell (http://wadler.blogspot.com/). I've taken a first stab at turning it into actual code for hackage (http://hpaste.org/13215). There are two commented-out definitions that don't type-check, though, and the types are too wild for me to grok. Anybody have any suggestions for 1.) How to fix it and/or 2.) How to use data/type/newtype to simplify the types and make it more manageable? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/eacc26fa/attachment.htm From briqueabraque at yahoo.com Sat Dec 20 18:28:40 2008 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sat Dec 20 18:21:17 2008 Subject: [Haskell-cafe] Is this related to monomorphism restriction? Message-ID: Hi, Why isn't the last line of this code allowed? f :: (TestClass a) => a -> Integer f = const 1 a = (f,f) g = fst a The only thing I can think about is monomorphism restriction, but it's allowed (or even the third line would not be accepted). Is there something I could read to understand that? Thanks, Maur?cio From lrpalmer at gmail.com Sat Dec 20 18:36:57 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Dec 20 18:29:23 2008 Subject: [Haskell-cafe] Is this related to monomorphism restriction? In-Reply-To: References: Message-ID: <7ca3f0160812201536j4ddf5f41yf6596072ae91b86e@mail.gmail.com> On Sat, Dec 20, 2008 at 4:28 PM, Maur??cio wrote: > Hi, > > Why isn't the last line of this code allowed? > > f :: (TestClass a) => a -> Integer > f = const 1 > a = (f,f) > g = fst a Yep, monomorphism restriction. a, because it is syntactically not a function, must not be typeclass polymorphic (without a type signature). So it tries to default, and TestClass probably doesn't have any defaults. Luke > > > The only thing I can think about is monomorphism > restriction, but it's allowed (or even the third > line would not be accepted). Is there something > I could read to understand that? > > Thanks, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/1b014896/attachment.htm From reiner.pope at gmail.com Sat Dec 20 18:56:18 2008 From: reiner.pope at gmail.com (Reiner Pope) Date: Sat Dec 20 18:48:45 2008 Subject: [Haskell-cafe] Is this related to monomorphism restriction? In-Reply-To: References: Message-ID: <4cf038ee0812201556m7fe8d3dfnd4a36bc8490caa3e@mail.gmail.com> On Sun, Dec 21, 2008 at 10:28 AM, Maur??cio wrote: > Hi, > > Why isn't the last line of this code allowed? > > f :: (TestClass a) => a -> Integer > f = const 1 > a = (f,f) > g = fst a > > The only thing I can think about is monomorphism > restriction, but it's allowed (or even the third > line would not be accepted). Is there something > I could read to understand that? > > Thanks, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > The monomorphism restriction refuses to accept the definition of a. However, even if we turn the monomorphism restriction off there is still a problem. > {-# LANGUAGE NoMonomorphismRestriction #-} > > f :: (TestClass a) => a -> Integer > f = const 1 > a = (f,f) > g = fst a In this case, the definition of a is accepted, but not the definition of g. The reason is that a has type a :: (TestClass a, TestClass b) => (a,b) and then when we take 'fst' of this value (as in g) we get g :: (TestClass a, TestClass b) => a which is an ambiguous type, since there is no way to tell the compiler what 'b' is when running g. Cheers, Reiner From bhurt at spnz.org Sat Dec 20 20:20:21 2008 From: bhurt at spnz.org (Brian Hurt) Date: Sat Dec 20 20:12:53 2008 Subject: [Haskell-cafe] Type classes vr.s functions Message-ID: So, style question for people, if I can. I have a certain problem- basically, I have a bunch of functions which need a special function, of type a -> Foo say. And a bunch of other functions which can define that function on some type of interest, and then what to call the first batch of functions. I can do this either by defining a type class, something like: class Fooable a where toFoo :: a -> Foo or I can simply have all the functions which need a toFoo take an extra agrument. Performance really isn't that important here, so it's really a matter of style- which approach would people prefer in this case? Brian From bhurt at spnz.org Sat Dec 20 20:35:09 2008 From: bhurt at spnz.org (Brian Hurt) Date: Sat Dec 20 20:27:43 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: <494811DD.5070908@btinternet.com> References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> Message-ID: (Sorry for the late reply) On Tue, 16 Dec 2008, Andrew Coppin wrote: > Don Stewart wrote: >> I think of Haskell more as a revolutionary movement > > LOL! Longest revolution EVER, eh? I mean, how long ago was its dogma first > codified? ;-) Remember: the eternal union of soviet socialist states lasted about 7 times as long as Hitler's thousand-year Reich (meanwhile, Jefferson's temporary experiment still seems to be lurching along about as well as ever). Nothing is as permanent as that which is declared temporary, and nothing is as temporary as that which is declared permanent. Also, constants aren't and variables don't. > > The thing that saddens me is this: > > http://prog21.dadgum.com/31.html > > Basically, Haskell will never be popular, but its coolest ideas will be > stolen by everybody else and passed off as their own. :-( We should be so lucky. My deepest fears is that Haskell doesn't become popular *and* it's ideas aren't picked up by other languages. Brian From carette at mcmaster.ca Sat Dec 20 21:34:50 2008 From: carette at mcmaster.ca (Jacques Carette) Date: Sat Dec 20 21:27:36 2008 Subject: [Haskell-cafe] Pattern combinators In-Reply-To: References: Message-ID: <494DAB4A.5080509@mcmaster.ca> Andrew Wagner wrote: > Wadler posted a blog entry the other day about a paper on > pattern-matching in Haskell (http://wadler.blogspot.com/). I've taken > a first stab at turning it into actual code for hackage > (http://hpaste.org/13215). There are two commented-out definitions > that don't type-check, though, and the types are too wild for me to > grok. Anybody have any suggestions for 1.) How to fix it and/or 2.) > How to use data/type/newtype to simplify the types and make it more > manageable? Thanks! Both errors are because you are using "any" instead of "any'"; you might wish to put import Prelude hiding any at the top of your code, just to avoid such confusion. To make the types more readable (but not necessarily more manageable), I have made some changes to my version of this code. For example, instead of () as the "empty stack", I use data Void void = undefined :: Void in the definition of 'zero' (and thus also in p .>. k). I also use data FUnit = FUnit -- Unit just for fail Lastly, instead of having a matcher be a pair (which obscures the use of pairs as a stack in other places, as well as matching on pairs), I defined data Matcher a b = Matcher a b and use that everywhere. This all makes the types larger to type, but at least there is a cleaner separation of concerns, which makes the errors easier to figure out. The principal weakness of these pattern-matching combinators is that there is no support for algebraic types, i.e. things like data Tree a = Leaf | Branch (Tree a) (Tree a) I can see how to use Typeable to deal with that, but is there a simpler way? Jacques From rfhayes at reillyhayes.com Sat Dec 20 23:59:42 2008 From: rfhayes at reillyhayes.com (R Hayes) Date: Sat Dec 20 23:52:10 2008 Subject: [Haskell-cafe] Cabal Install & Links to Source from Haddock Docs Message-ID: Is there a way I can get Haddock Docs WITH links to source (local) from modules installed with "cabal install xxx"? Getting the docs themselves is pretty easy by changing either ~/.cabal/ config or using --enable-documentation. Automatically generating the source (colourised or not) and integrated links eludes me. -r From artyom.shalkhakov at gmail.com Sun Dec 21 00:35:53 2008 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Sun Dec 21 00:28:21 2008 Subject: [Haskell-cafe] understanding enumerator/iteratee In-Reply-To: <42784f260812200111y320fafd4ja8d8bb1a52573808@mail.gmail.com> References: <42784f260812200111y320fafd4ja8d8bb1a52573808@mail.gmail.com> Message-ID: <2076f2f90812202135o6db3a3b0t2971d5f8ca6cb39f@mail.gmail.com> Hi Jason, 2008/12/20 Jason Dusek : > So, it looks Iteratee takes a "step" on the resource -- > whatever it is -- and Enumerator manages the resource and > sequences the steps of the Iteratee. The Enumerator, then, > defines our way of managing a particular resource -- how to > take a step, how to close it, &c. -- while the Iteratee > describes a computation that computes an output and also tells > us when to free the resource. Yes, I believe you are correct. > Is that a correct interpretation? I find the material on > Enumerator and Iterator to be vague (or at least not very > concrete). Have you read Oleg's DEFUN'08 talk notes? [1] Having read them more than once, I find them comprehensible. :) Cheers, Artyom Shalkhakov. [1] From allbery at ece.cmu.edu Sun Dec 21 00:35:47 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Dec 21 00:28:30 2008 Subject: [Haskell-cafe] Type classes vr.s functions In-Reply-To: References: Message-ID: <1A6B2D56-EE6C-4FA4-BFA3-00FDC4CF04C4@ece.cmu.edu> On 2008 Dec 20, at 20:20, Brian Hurt wrote: > class Fooable a where > toFoo :: a -> Foo > or I can simply have all the functions which need a toFoo take an > extra > agrument. Performance really isn't that important here, so it's > really > a matter of style- which approach would people prefer in this case? A third possibility is to use the simple Reader monad ((->) r). -- 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 allbery at ece.cmu.edu Sun Dec 21 00:37:00 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Dec 21 00:29:31 2008 Subject: [Haskell-cafe] Haskell as a religion In-Reply-To: References: <7b92c2840812161000ief6dbecx19b0c0d0ca1ce635@mail.gmail.com> <49480D57.5070706@cogito.org.uk> <20081216203427.GD32325@scytale.galois.com> <494811DD.5070908@btinternet.com> Message-ID: <2A8CC00A-B93E-40D0-9C4A-AEC7395E0E19@ece.cmu.edu> On 2008 Dec 20, at 20:35, Brian Hurt wrote: > We should be so lucky. My deepest fears is that Haskell doesn't > become popular *and* it's ideas aren't picked up by other languages. No worries: they *are* being picked up, piece by piece. -- 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 dave at zednenem.com Sun Dec 21 00:37:40 2008 From: dave at zednenem.com (David Menendez) Date: Sun Dec 21 00:30:05 2008 Subject: [Haskell-cafe] Pattern combinators In-Reply-To: <494DAB4A.5080509@mcmaster.ca> References: <494DAB4A.5080509@mcmaster.ca> Message-ID: <49a77b7a0812202137j23ff10edw1853f5a24eb6aae9@mail.gmail.com> On Sat, Dec 20, 2008 at 9:34 PM, Jacques Carette wrote: > Andrew Wagner wrote: >> >> Wadler posted a blog entry the other day about a paper on pattern-matching >> in Haskell (http://wadler.blogspot.com/). I've taken a first stab at turning >> it into actual code for hackage (http://hpaste.org/13215). There are two >> commented-out definitions that don't type-check, though, and the types are >> too wild for me to grok. Anybody have any suggestions for 1.) How to fix it >> and/or 2.) How to use data/type/newtype to simplify the types and make it >> more manageable? Thanks! > > Both errors are because you are using "any" instead of "any'"; you might > wish to put > import Prelude hiding any > at the top of your code, just to avoid such confusion. Example 14 also uses (.->.) where it should use (.>.), and it either needs some more parentheses or some precedence declarations for the operators. > To make the types more readable (but not necessarily more manageable), I > have made some changes to my version of this code. One oddity in the paper is the type of the failure continuations, () -> ans. I'm guessing that's left over from an earlier phase of development. In my own transcription of the library, I eliminated the () parameter without apparent loss of functionality. I think I've managed to work out the structure of the types, which can mostly be expressed in modern Haskell. The matching part of the patterns have this general form: type PMatch vec vec' ans = (vec -> ans) -> (() -> ans) -> vec' -> ans where vec and vec' are the list of argument types before and after the subpattern match, and ans is the final answer. (In my code, I just use ans instead of () -> ans for the failure continuation.) This gets us: nil :: PMatch vec vec ans one :: a -> PMatch (a,vec) vec ans (#) :: PMatch vec vec' ans -> PMatch vec' vec'' ans -> PMatch vec vec'' ans fail :: PMatch vec vec' ans catch :: PMatch vec vec' ans -> PMatch vec vec' ans -> PMatch vec vec' ans These types are less general than the ones Haskell would infer, but they do not appear to lose any functionality. The currying part of the pattern is less easy to analyze. I've been able to use type families to relate the curried and uncurried form of the function types, but I'm working with GHC 6.8, so it's possible this won't work with the more modern implementations. Given the list of argument types and the answer type, generate a curried function type: type family Curry vec ans type instance Curry () ans = ans type instance Curry (a,vec) ans = a -> Curry vec ans zero, succ zero, and so forth take a function in curried form and transform it into a function that takes a nested tuple: type CurryDigit vec ans = Curry vec ans -> vec -> ans zero :: CurryDigit () ans succ zero :: CurryDigit (a,()) ans succ :: CurryDigit vec ans -> CurryDigit (a,vec) ans succ . succ :: CurryDigit vec ans -> CurryDigit (a,(b,vec)) ans So the currying part of the pattern will have the form: type PCurry vec vec' ans = CurryDigit vec' ans -> CurryDigit vec ans So a pattern has the type, type Pattern a vec vec' ans = (PCurry vec vec' ans, a -> PMatch vec vec' ans) where a is the value being examined, vec and vec' are the list of unbound argument types before and after the match, and ans is the result. var :: Pattern a (a,vec) vec ans cst :: (Eq a) => a -> Pattern a vec vec ans pair :: Pattern a vec vec' ans -> Pattern b vec' vec'' ans -> Pattern (a,b) vec vec'' ans Coming from the other side, match takes a value and a case statement and produces a result: type Case a ans = a -> (() -> ans) -> ans -- or just a -> ans -> ans in my code match :: a -> Case a ans -> ans (|||) combines case statements: (|||) :: Case a ans -> Case a ans -> Case a ans and (->>) creates them from a pattern and a curried function, (->>) :: Pattern a vec () ans -> Curry vec ans -> Case a ans Note that (->>) requires the pattern to leave no unbound variables after matching. Given the way everything is polymorphic in ans, it may be possible to hide it, but I haven't tried yet. > The principal weakness of these pattern-matching combinators is that there > is no support for algebraic types, i.e. things like > data Tree a = Leaf | Branch (Tree a) (Tree a) > I can see how to use Typeable to deal with that, but is there a simpler way? You can define the patterns manually: leaf = (id, \v -> case v of { Leaf -> nil; _ -> fail }) branch p q = (curry_p . curry_q, \v -> case v of { Branch l r -> match_p l # match_q r; _ -> fail}) where (curry_p, match_p) = p (curry_q, match_q) = q I assume generating these would be pretty straightforward to automate with Template Haskell. -- Dave Menendez From kyagrd at gmail.com Sun Dec 21 00:45:43 2008 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Sun Dec 21 00:56:07 2008 Subject: [Haskell-cafe] Graham Hutton's calculator example for win32 Message-ID: <494DD807.4060004@gmail.com> In Graham Hutton's "Programming in Haskell" there is an interactive calculator example using ANSI code to implement the UI on the terminal. This example doesn't work on MS Windows XP or other MS OSes based on NT kernel, since their command line does not support ANSI very well. But, thanks to ansi-terminal on Hackage, I was able to extract minimal code from the package to make a win32 version of the calculator example in Hutton's book. calculatorWin32.lhs and Win32ANSI.hs is an implementation for win32. I extracted the win32 console API bindings for setting cursor positions from ansi-terminal project and put them in Win32ANSI.hs. I had to put this in a separate file because I had an issue with ghci. To run this, I had to compile the console API bindings with ghc first and then run ghci as follows C:\> ghc -c Win32ANSI.hs C:\> ghci calculatorWin32.lhs Without compiling the object code, ghci cannot find the proper link for win32 console API FFI bindings. C:\> ghci calculatorWin32.lhs GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 3] Compiling Parsing ( Parsing.lhs, interpreted ) [2 of 3] Compiling Win32ANSI ( Win32ANSI.hs, interpreted ) During interactive linking, GHCi couldn't find the following symbol: GetConsoleScreenBufferInfo@8 This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please send a bug report to: glasgow-haskell-bugs@haskell.org Is this a bug or a natural behavior of ghci? This is strange to me since ghci finds the proper link for the functions in the other C libraries such as getch in conio.h. In addition, I am attaching a patched calculator.lhs which works for Unix/Linux on both GHC 6.8.x and GHC 6.10.1. The one currently on the book homepage only works for GHC 6.8.x but not GHC 6.10.1. This is due to the bug fix of hSetBuffering in GHC 6.10.1. To run these calculator example you will also need Parsing.lhs from the book hompage. http://www.cs.nott.ac.uk/~gmh/Parsing.lhs -- Ahn, Ki Yung -------------- next part -------------- A non-text attachment was scrubbed... Name: calculator.lhs Type: text/x-literate-haskell Size: 5984 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/6af43844/calculator-0001.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: calculatorWin32.lhs Type: text/x-literate-haskell Size: 6328 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/6af43844/calculatorWin32-0001.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: Win32ANSI.hs Type: text/x-haskell Size: 8105 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/6af43844/Win32ANSI-0001.bin From lrpalmer at gmail.com Sun Dec 21 01:08:21 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 21 01:00:47 2008 Subject: [Haskell-cafe] Type classes vr.s functions In-Reply-To: References: Message-ID: <7ca3f0160812202208i391fc240v5731f425be2aabd5@mail.gmail.com> On Sat, Dec 20, 2008 at 6:20 PM, Brian Hurt wrote: > > So, style question for people, if I can. I have a certain problem- > basically, I have a bunch of functions which need a special function, > of type a -> Foo say. And a bunch of other functions which can define > that function on some type of interest, and then what to call the first > batch of functions. I can do this either by defining a type class, > something like: > class Fooable a where > toFoo :: a -> Foo > or I can simply have all the functions which need a toFoo take an extra > agrument. Performance really isn't that important here, so it's really > a matter of style- which approach would people prefer in this case? And it doesn't matter as the performance would be the same in the two cases also. My general rule of thumb is to always write combinators first, since they do not suffer the composability limitations that typeclasses do (rougly typeclasses perform a proof search which is subject to restrictions to ensure decidability, whereas with combinators you provide the proof, so there are no such restrictions). Then typeclass instances can be trivially defined in terms of the combinators. Note that the other way around is not usually possible. So eg.: module Foo where type Fooify a = a -> Foo int :: Fooify Int int = ... list :: Fooify a -> Fooify [a] list = ... -- then, if determined that this would be convenient class Fooable a where toFoo :: Fooify a instance Fooable Int where toFoo = int instance (Fooable a) => Fooable [a] where toFoo = list toFoo ... Luke > > Brian > > _______________________________________________ > 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/20081220/c91ef566/attachment.htm From pete at petertodd.org Sun Dec 21 03:02:01 2008 From: pete at petertodd.org (Peter Todd) Date: Sun Dec 21 02:55:10 2008 Subject: [Haskell-cafe] "Rewrite thunk action" rule? Message-ID: <20081221080201.GB26638@petertodd.org> I have a program with this data structure: data Element = Element { elementOrigin :: V, elementSubs :: [Element] } and this important bit of code that operates on it: transform :: T -> Element -> Element transform t e = Element { elementOrigin = tmulv t (elementOrigin e), elementSubs = map (transform t) (elementSubs e) } Where V is a vertex and T is a matrix transformation. The following is true: transform a (transform b e) == transform (a * b) e I have read about rewrite rules, such would efficiently rewrite the obvious transformations. However, given that the program will be applying *many* transformations to very deep and wide Element trees, and applying those transformations at many levels, I don't see how the optimizer would be able to handle all cases, for instance a thunk getting left over from perhaps evaluation prior to some IO function. FWIW here's an example "tree-builder" I'm using to test with: mkElems 0 _ = Element { elementOrigin = V 0 0, elementSubs = [] } mkElems depth width = Element { elementOrigin = V 0 0, elementSubs = replicate width $ transform (rotation (pi / (fromIntegral width))) $ transform (translation $ V 1 1) $ mkElems (depth - 1) width } with depth = width = 5 If I could somehow arrange for the transform function to detect when it is being applied to a unevaluated thunk, and then modify the thunk in place, that would basically be the behavior I need. Any suggestions? -- http://petertodd.org 'peter'[:-1]@petertodd.org -------------- 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/20081221/5a1cfbc8/attachment.bin From kyrab at mail.ru Sun Dec 21 03:06:32 2008 From: kyrab at mail.ru (kyra) Date: Sun Dec 21 02:58:59 2008 Subject: [Haskell-cafe] Trouble with FFI on Windows2000... In-Reply-To: References: Message-ID: <494DF908.9090409@mail.ru> Serge LE HUITOUZE wrote: > I do the following: > >> dlltool -d cproj1.def -l libcproj1.a >> ghc --make testFFI_2.hs -optl-lcproj1 -optl-L. >> > > This seems fine, since it produces a "testFFI_2.exe". > However, executing it, I get a MSWindows error box with a message > that looks like (approximate translation): > "DLL (null) not found on specified path" > > At first, I didn't have the "LIBRARY" directive in the ".def" file, > so I thought that was the reason for the "(null)" appearing in the > message. But adding said directive didn't change anything... > > dlltool -d cproj1.def -l libcproj1.a -D cproj1.dll From jon at ffconsultancy.com Sun Dec 21 03:54:49 2008 From: jon at ffconsultancy.com (Jon Harrop) Date: Sun Dec 21 03:44:14 2008 Subject: [Haskell-cafe] Line noise In-Reply-To: References: <48D68F22.1090808@btinternet.com> <48D707AF.100@freegeek.org> Message-ID: <200812210854.50008.jon@ffconsultancy.com> On Tuesday 23 September 2008 02:27:17 Brian Hurt wrote: > On Sun, 21 Sep 2008, wren ng thornton wrote: > > Even with functionalists ---of the OCaml and SML ilk--- > > this use of spaces can be confusing if noone explains that function > > application binds tighter than all operators. > > Bwuh? Ocaml programmers certainly know that application binds tighter > than operators. And as: > > let f x y = ... in > f a b > > is more efficient (in Ocaml) than: > > let f (x, y) = ... in > f (a, b) > > (Ocaml doesn't optimize away the tuple allocation)... That is incorrect. OCaml does optimize away that tuple: both forms compile to the same 2-argument function. OCaml does not optimize away this tuple: let a, b = 1, 2 So, when efficiency is important, you write: let a = 1 and b = 2 -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From tphyahoo at gmail.com Sun Dec 21 04:11:44 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Dec 21 04:04:09 2008 Subject: [Haskell-cafe] Cabal Install & Links to Source from Haddock Docs In-Reply-To: References: Message-ID: <910ddf450812210111o5968073bm7d904107259ee7d6@mail.gmail.com> the answer: not cabal install, just cabal. thartman@thartman-laptop:~/haskellInstalls/smallInstalls/pureMD5-0.2.3> thartman@thartman-laptop:~/haskellInstalls/smallInstalls/pureMD5-0.2.3>cabal --help | grep -i doc haddock Generate Haddock HTML documentation. thartman@thartman-laptop:~/haskellInstalls/smallInstalls/pureMD5-0.2.3>cabal haddock --help | grep -i link --hyperlink-source Hyperlink the documentation to the source code thartman@thartman-laptop:~/haskellInstalls/smallInstalls/pureMD5-0.2.3>cabal haddock --hyperlink-source 2008/12/21 R Hayes : > > Is there a way I can get Haddock Docs WITH links to source (local) from > modules installed with "cabal install xxx"? > > Getting the docs themselves is pretty easy by changing either > ~/.cabal/config or using --enable-documentation. > > Automatically generating the source (colourised or not) and integrated links > eludes me. > > -r > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lrpalmer at gmail.com Sun Dec 21 04:56:06 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 21 04:48:32 2008 Subject: [Haskell-cafe] "Rewrite thunk action" rule? In-Reply-To: <20081221080201.GB26638@petertodd.org> References: <20081221080201.GB26638@petertodd.org> Message-ID: <7ca3f0160812210156m2b2a194br7f0870644a799287@mail.gmail.com> 2008/12/21 Peter Todd > If I could somehow arrange for the transform function to detect when it > is being applied to a unevaluated thunk, and then modify the thunk in > place, that would basically be the behavior I need. Any suggestions? That is exactly what is already happening. Perhaps you want what you think is happening: if a value *is* evaluated, you want to apply the transformation right then instead of making a thunk. By the way, this is very operational thinking for Haskell. Haskell tries quite hard to abstract away operational thinking, so thinking on this level will be difficult and more work than you should be doing to write a program. May I ask why you want this behavior? Have you just tested it and observed that it is running too slowly and you are trying to speed it up? Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/7bec6d68/attachment.htm From jon at ffconsultancy.com Sun Dec 21 06:17:55 2008 From: jon at ffconsultancy.com (Jon Harrop) Date: Sun Dec 21 06:07:19 2008 Subject: [Haskell-cafe] Re: Windows vs. Linux x64 In-Reply-To: <49426DD8.9030605@gmail.com> References: <200811250056.27632.bartek@sudety.it> <20081126011626.GC9558@sliver.repetae.net> <49426DD8.9030605@gmail.com> Message-ID: <200812211117.55584.jon@ffconsultancy.com> On Friday 12 December 2008 13:57:44 Simon Marlow wrote: > - it means recompiling *everything*. It's a complete new way, so you > have to make the decision to do this once and for all, or build all > your libraries + RTS twice. In JITed languages they can make the > choice at runtime, which makes it much easier. Is anyone developing a JIT Haskell compiler? The approach has many important practical benefits and tools like LLVM are a joy to use... -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From ndmitchell at gmail.com Sun Dec 21 06:20:28 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sun Dec 21 06:12:53 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: Hoogle with more libraries In-Reply-To: <93EF0BE3-0792-40BF-B07B-8C3FAC290CFD@gmail.com> References: <404396ef0812210255u2d67ebd9l90a55121ea26b493@mail.gmail.com> <93EF0BE3-0792-40BF-B07B-8C3FAC290CFD@gmail.com> Message-ID: <404396ef0812210320u6867c44cvabf7dec820dfac39@mail.gmail.com> Hi Bob, > 1. Searching using a package name that isn't all lower case results in > nothing (e.g. (a -> b) -> f a -> f b +InfixApplicative gives no results, > while (a -> b) -> f a -> f b +infixapplicative gives 2). Yes, if you do +InfixApplicative it assumes you mean only in the module InfixApplicative, not the package. Module is upper case, package starts with lowercase. > 2. Searching with the +package syntax seems to remove all other possible > results. Perhaps it would be nice to show results from the default library > set below. Add +default to search the default too. > If you get the package name wrong (i.e. specify a package that hoogle can't > see), it would be nice for it to report something like google does -- maybe > you meant xyz. Definately! The whole area needs an overhall. Thanks Neil From nhn at Cs.Nott.AC.UK Sun Dec 21 07:10:06 2008 From: nhn at Cs.Nott.AC.UK (Henrik Nilsson) Date: Sun Dec 21 07:03:27 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> Message-ID: <494E321E.3040905@cs.nott.ac.uk> Hi Tom, > In reactive, one doesn't. All behaviors and events have the same > absolute 0 value for time. Right. I believe the possibility of starting behaviors later is quite important. And from what Conal wrote in a related mail, I take it that this is recognized, and that this capability is something that is being considered for reactive? Best, /Henrik -- Henrik Nilsson School of Computer Science The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From paul at cogito.org.uk Sun Dec 21 07:12:03 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Sun Dec 21 07:04:31 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: References: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> <125EACD0CAE4D24ABDB4D148C4593DA9049E97D0@GBLONXMB02.corp.amvescap.net> Message-ID: <494E3293.1080603@cogito.org.uk> Paulo Tanimoto wrote: > Another idea: something in the form of an Ouroboros. Is that already > "taken" for a programming language? > > http://en.wikipedia.org/wiki/Ouroboros > Something like this? http://www.haskell.org/sitewiki/images/f/fd/Ouroborous-oval.png Paul From martijn at van.steenbergen.nl Sun Dec 21 08:52:07 2008 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sun Dec 21 08:44:32 2008 Subject: [Haskell-cafe] Comparing on multiple criteria Message-ID: <494E4A07.7040807@van.steenbergen.nl> Hello all, Data.Ord has a handy function called comparing, and its documentation shows an example of its use. But what if you want to sort a list of values based on multiple criteria? It turns out there is a neat way to do this: compareTuple = mconcat [comparing fst, comparing snd] The default Monoid instances for Ordering and functions work exactly as required here. (Thanks to vixey in #haskell for the hint to look at monoids!) To reverse the order of a criterion or a set of criteria, flip can be used: compareTuple' = mconcat [comparing fst, flip $ comparing snd] I think it would be really neat if these two use cases were also described in comparing's documentation. Who is the right person to ask this of? Thanks in advance, Martijn. From pkeir at dcs.gla.ac.uk Sun Dec 21 08:59:10 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Sun Dec 21 08:55:02 2008 Subject: [Haskell-cafe] forkIO on multicore References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <494BCEF6.8090707@pikewerks.com> <1229709140.10115.782.camel@localhost> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCB2B@EX2.ad.dcs.gla.ac.uk> > So this benchmark is primarily a stress test of the parallel garbage > collector since it is GC that is taking 75-80% of the time. Note that > the mutator elapsed time goes down slightly with 2 cores compared to 1 > however the GC elapsed time goes up slightly. Thanks Duncan, Jake et al. I'm more familiar with MPI and OpenMP for parallelism; it seems I've got a lot more thinking to do when it comes to Haskell. I'll look at some more tutorials, and then most likely Data Parallel Haskell. Cheers, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/2f614a7b/attachment.htm From jmaessen at alum.mit.edu Sun Dec 21 11:20:02 2008 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Sun Dec 21 11:12:30 2008 Subject: [Haskell-cafe] Comparing on multiple criteria In-Reply-To: <494E4A07.7040807@van.steenbergen.nl> References: <494E4A07.7040807@van.steenbergen.nl> Message-ID: <71B0F62F-5B5B-4F57-B280-23F4CF2E917E@alum.mit.edu> On Dec 21, 2008, at 8:52 AM, Martijn van Steenbergen wrote: > Hello all, > > Data.Ord has a handy function called comparing, and its > documentation shows an example of its use. > > But what if you want to sort a list of values based on multiple > criteria? It turns out there is a neat way to do this: > > compareTuple = mconcat [comparing fst, comparing snd] > > The default Monoid instances for Ordering and functions work exactly > as required here. (Thanks to vixey in #haskell for the hint to look > at monoids!) Indeed, this is great to know. I can't help but notice that there is no documentation of any kind at all for the Monoid instance of Ordering; how were we supposed to know this behavior existed in the first place, except by hunting down the source code for the instance declaration? -Jan-Willem Maessen From lrpalmer at gmail.com Sun Dec 21 11:35:18 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 21 11:27:44 2008 Subject: [Haskell-cafe] Comparing on multiple criteria In-Reply-To: <71B0F62F-5B5B-4F57-B280-23F4CF2E917E@alum.mit.edu> References: <494E4A07.7040807@van.steenbergen.nl> <71B0F62F-5B5B-4F57-B280-23F4CF2E917E@alum.mit.edu> Message-ID: <7ca3f0160812210835mbf1c15dxa5b3dbcfc4eba3fb@mail.gmail.com> On Sun, Dec 21, 2008 at 9:20 AM, Jan-Willem Maessen wrote: > Indeed, this is great to know. I can't help but notice that there is no > documentation of any kind at all for the Monoid instance of Ordering; how > were we supposed to know this behavior existed in the first place, except by > hunting down the source code for the instance declaration? > It seems we have no good way to associate documentation with instances. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/4fa4c191/attachment.htm From briqueabraque at yahoo.com Sun Dec 21 12:21:14 2008 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Dec 21 12:13:50 2008 Subject: [Haskell-cafe] Re: Is this related to monomorphism restriction? In-Reply-To: <4cf038ee0812201556m7fe8d3dfnd4a36bc8490caa3e@mail.gmail.com> References: <4cf038ee0812201556m7fe8d3dfnd4a36bc8490caa3e@mail.gmail.com> Message-ID: >> Why isn't the last line of this code allowed? >> f :: (TestClass a) => a -> Integer >> f = const 1 >> a = (f,f) >> g = fst a >> The only thing I can think about is monomorphism >> restriction, but it's allowed (...) > (...) The reason is that a has type > a :: (TestClass a, TestClass b) => (a,b) > and then when we take 'fst' of this value (as in g) we get > g :: (TestClass a, TestClass b) => a > which is an ambiguous type, (...) Is there some version (i.e., set of extensions) of Haskell where this would be allowed? From pete at petertodd.org Sun Dec 21 12:27:16 2008 From: pete at petertodd.org (Peter Todd) Date: Sun Dec 21 12:20:24 2008 Subject: [Haskell-cafe] "Rewrite thunk action" rule? In-Reply-To: <7ca3f0160812210156m2b2a194br7f0870644a799287@mail.gmail.com> References: <20081221080201.GB26638@petertodd.org> <7ca3f0160812210156m2b2a194br7f0870644a799287@mail.gmail.com> Message-ID: <20081221172716.GC26638@petertodd.org> On Sun, Dec 21, 2008 at 02:56:06AM -0700, Luke Palmer wrote: > 2008/12/21 Peter Todd > > > If I could somehow arrange for the transform function to detect when it > > is being applied to a unevaluated thunk, and then modify the thunk in > > place, that would basically be the behavior I need. Any suggestions? > > > That is exactly what is already happening. Perhaps you want what you think > is happening: if a value *is* evaluated, you want to apply the > transformation right then instead of making a thunk. Not quite. If I have a thunk, at the low level somewhere it must refer to the transform function, the transform matrix, and the element that is to be transformed. If I apply another transform to that unevaluated thunk, my understanding is that haskell will represent it as such: thunk transform Ta (thunk transform Tb e) When I want the following: thunk transform (Ta * Tb) e This alternate definition of the Element structure might make more sense: data Element = Element { elementOrigin :: V, elementSubs :: [Element] } | ElementThunk T Element transform :: T -> Element -> Element transform t (ElementThunk t2 e) = ElementThunk (tmul t t2) e transform t e = ElementThunk t e transform t e = Element { elementOrigin = tmulv t (elementOrigin e), elementSubs = map (transform t) (elementSubs e) } This gives a behavior close to what I want, applying a transform to an element results in a "thunk", and subsequent transforms simply modify the thunk, the problem is that I don't see a way to implicitly coerce an ElementThunk into an Element on demand for all the other code in the program that expects elements. (such as the elementOrigin function) > By the way, this is very operational thinking for Haskell. Haskell tries > quite hard to abstract away operational thinking, so thinking on this level > will be difficult and more work than you should be doing to write a program. Yes, but this part of the program is library code, that will be used by a whole pile of other stuff, so if I can get the right behavior "magically" the rest of the program will be a lot easier to write. FWIW this is EDA software, those "elements" refer to elements of a printed circuit board layout, and the transform operations correspond to stuff like moving a chip on the board. The representation of a simple IC would consist of something like an element, with a bunch of sub-elements for each pin, all of which have geometry data. > May I ask why you want this behavior? Have you just tested it and observed > that it is running too slowly and you are trying to speed it up? I've written a previous version of this program in Python actually, where I explicitly modeled the lazy evaluation behavior that I wanted. It all worked great, but the overall speed was still quite slow. I was hoping that Haskell, built around lazy evaluation already, would be a better fit. That, and in any case, other aspects of the program that I've re-written in Haskell saw about a 5-1 redunction in code length... :) -- http://petertodd.org 'peter'[:-1]@petertodd.org -------------- 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/20081221/4d1a6c66/attachment.bin From lrpalmer at gmail.com Sun Dec 21 13:10:15 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 21 13:02:39 2008 Subject: [Haskell-cafe] "Rewrite thunk action" rule? In-Reply-To: <20081221172716.GC26638@petertodd.org> References: <20081221080201.GB26638@petertodd.org> <7ca3f0160812210156m2b2a194br7f0870644a799287@mail.gmail.com> <20081221172716.GC26638@petertodd.org> Message-ID: <7ca3f0160812211010x73314161h9e3d1e0a15c86326@mail.gmail.com> On Sun, Dec 21, 2008 at 10:27 AM, Peter Todd wrote: > > data Element = Element { > elementOrigin :: V, > elementSubs :: [Element] > } > | ElementThunk T Element > > transform :: T -> Element -> Element > transform t (ElementThunk t2 e) = ElementThunk (tmul t t2) e > transform t e = ElementThunk t e > transform t e = Element { > elementOrigin = tmulv t (elementOrigin e), > elementSubs = map (transform t) (elementSubs e) > } > > This gives a behavior close to what I want, applying a transform to an > element results in a "thunk", and subsequent transforms simply modify > the thunk, the problem is that I don't see a way to implicitly coerce an > ElementThunk into an Element on demand for all the other code in the > program that expects elements. (such as the elementOrigin function) Oh! Okay, studying your code a bit, I think I finally understand what you're trying to do. Tell me if I'm wrong. You have a list of elements es and a composition of transforms t1,t2,t3, and instead of applying t1, t2, and t3 to each element, you want to collapse them together into a single matrix and apply that matrix to each element. This is definitely a modeling level thing to do; you don't need to go anywhere near rewrite rules or thinking about internal representations or anything like that. A bit of old fashioned abstraction should do the trick. Your Thunk representation is not that bad. I can't really weigh the trade-offs for you. Keep the data type abstract and only allow access through functions (like elementOrigin). Then I don't see the problem with redefining elementOrigin as: elementOrigin (Element v subs) = v elementOrigin (ElementThunk t e) = tmulv t (elementOrigin e) Keep the number of operations which need to know the representation (constructors) of Element as small as you can. Another possibility is this: data Element = Element { elementOrigin :: V , elementSubs :: [(T,Element)] } Where, of course, the transform for each sub-element is relative. Overall I think your "thunk" solution is a very nice trade-off. (Minor rhetorical note: I would probably name your ElementThunk constructor Transform or ElementTransform instead) Hmm, you have an invariant that the pattern ElementThunk t (ElementThunk t e) never occurs. It would be good style to encode this: data PrimElement = PrimElement { elementOrigin :: V, elementSubs :: [Element] } data Element = Element (Maybe T) PrimElement That Maybe bugs me. You could factor that out into the T type with a special optimization for the identity transform. Hmm, then the [(T,Element)] encoding and this one are identical. Fun. :-) Short answer: *abstract data type!* Luke > > > By the way, this is very operational thinking for Haskell. Haskell tries > > quite hard to abstract away operational thinking, so thinking on this > level > > will be difficult and more work than you should be doing to write a > program. > > Yes, but this part of the program is library code, that will be used by > a whole pile of other stuff, so if I can get the right behavior > "magically" the rest of the program will be a lot easier to write. > > FWIW this is EDA software, those "elements" refer to elements of a > printed circuit board layout, and the transform operations correspond to > stuff like moving a chip on the board. The representation of a simple IC > would consist of something like an element, with a bunch of sub-elements > for each pin, all of which have geometry data. > > > May I ask why you want this behavior? Have you just tested it and > observed > > that it is running too slowly and you are trying to speed it up? > > I've written a previous version of this program in Python actually, > where I explicitly modeled the lazy evaluation behavior that I wanted. > It all worked great, but the overall speed was still quite slow. I was > hoping that Haskell, built around lazy evaluation already, would be a > better fit. > > > That, and in any case, other aspects of the program that I've re-written > in Haskell saw about a 5-1 redunction in code length... :) > > -- > http://petertodd.org 'peter'[:-1]@petertodd.org > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > > iD8DBQFJTnx03bMhDbI9xWQRAhWvAJoD8JeQg/3Q3Oy5FNEAaVjbNDbg3QCfe5jJ > Ob2IGxR4YDfiVpoTeOFcnBM= > =RS6B > -----END PGP SIGNATURE----- > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/7c14586b/attachment.htm From ml at niaow.com Sun Dec 21 13:12:21 2008 From: ml at niaow.com (Laurent Giroud) Date: Sun Dec 21 13:03:56 2008 Subject: [Haskell-cafe] Removing/Uninstalling cabal packages ? Message-ID: Hi, I have been doing a few experiments with cabal packages lately and I wish to uninstall these to return to a cleaner package base. However, there doesn't seem to be a "cabal uninstall" command and reading the documentation at http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html does not tell much about how to do that manually. Note that what I wish to do is both delete the installed files and the cabal database so that the uninstalled packages does not show anymore when running "cabal list --installed". Would anyone know how to do that ? Thanks in advance. Regards, Laurent -- Laurent Giroud ml@niaow.com From s.clover at gmail.com Sun Dec 21 13:17:56 2008 From: s.clover at gmail.com (Sterling Clover) Date: Sun Dec 21 13:10:24 2008 Subject: [Haskell-cafe] ANN: bytestring-trie 0.1.0 In-Reply-To: <494C8B52.2040209@freegeek.org> References: <494C8B52.2040209@freegeek.org> Message-ID: Thanks for working on this! A nice efficient bytestring-trie is the sort of data structure we should have had in Haskell for some time now, and I'm sure I'll be giving it a great deal of use. Regards, Sterl. On Dec 20, 2008, at 1:06 AM, wren ng thornton wrote: > -------------------------------------------- > -- Announcing: bytestring-trie 0.1.0 (beta) > -------------------------------------------- > > An efficient finite map from (byte)strings to values. > > The implementation is based on big-endian patricia trees, like > Data.IntMap. We first trie on the Word8 elements of a > Data.ByteString, sharing string prefixes where possible, and then > trie on the big-endian bit representation of those elements. > Patricia trees have efficient algorithms for union and other > merging operations, but they're also quick for lookups and insertions. > > > -------------------------------------------- > -- Future Extensions > -------------------------------------------- > > * I've done spot checking to make sure it works, but haven't > constructed an extensive test suite. Does anyone know of a good > data set already out there for testing corner cases? I'm sure other > dictionary writers have come up with one. > > * A Word8 is much smaller than the architecture's natural Word > size. Therefore it'd be more efficient for the trie on bits to read > off a whole Word at a time. This work is in progress, but I need > help from people with 64-bit and big-endian machines in order to > verify the code works on those architectures. > > * Using ByteStrings allows for trieing on any packed byte > representation of a value, but they're not Strings. Integration > with Data.ByteString.Char8, utf8-string, and utf8-light should happen. > > * The current implementation also only accepts strict ByteStrings. > When chopping up strings to share prefixes we share the smaller > string. For very long strings when many deletions are expected, > this can still hold onto more memory than necessary. Accepting lazy > ByteStrings or adding heuristics for when to copy prefixes instead > of sharing will fix this. > > > -------------------------------------------- > -- Links > -------------------------------------------- > > Homepage: > http://code.haskell.org/~wren/ > > Hackage: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ > bytestring-trie > > Darcs: > http://code.haskell.org/~wren/bytestring-trie/ > > Haddock (Darcs version): > http://code.haskell.org/~wren/bytestring-trie/dist/doc/html/ > bytestring-trie/ > > -- > Live well, > ~wren > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From allbery at ece.cmu.edu Sun Dec 21 13:48:20 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Dec 21 13:40:51 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> Message-ID: <0F043848-06B3-47FD-AD01-69CF09E42C5E@ece.cmu.edu> On 2008 Dec 17, at 8:42, Darrin Thompson wrote: > X monad could have a variant of this logo too. >X= (That's how I > originally thought of it, just was too lazy to post it anywhere. Sorry > about that.) Or just a lambda with an extra contrasting stroke to make an X (?' very roughly, if you have the right font). -- 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 dvde at gmx.net Sun Dec 21 13:58:23 2008 From: dvde at gmx.net (Daniel van den Eijkel) Date: Sun Dec 21 13:50:56 2008 Subject: [Haskell-cafe] Logos of Other Languages In-Reply-To: <494E3293.1080603@cogito.org.uk> References: <35437412-8E4E-4DA7-96D6-407F7F7EA690@tobias-kraentzer.de> <125EACD0CAE4D24ABDB4D148C4593DA9049E97D0@GBLONXMB02.corp.amvescap.net> <494E3293.1080603@cogito.org.uk> Message-ID: <494E91CF.20003@gmx.net> what about such a variation? something between an ouroborob, a lambda and a mermaid... By the way: I mixed up something: My note, that the orouboros was used as a logo for Heinz von F?rsters second order cybernetics, was not correct. The correct note should have been: Heinz von F?rster, the later founder of the second order cybernetics, invented the ouroboros as a logo for the american society for cybernetics. http://www.asc-cybernetics.org/ daniel > Paulo Tanimoto wrote: >> Another idea: something in the form of an Ouroboros. Is that already >> "taken" for a programming language? >> >> http://en.wikipedia.org/wiki/Ouroboros >> > Something like this? > > http://www.haskell.org/sitewiki/images/f/fd/Ouroborous-oval.png > > Paul > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: lambda-ouroboros.JPG Type: image/jpeg Size: 20783 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/6a6d2d53/lambda-ouroboros-0001.jpg From ryani.spam at gmail.com Sun Dec 21 14:02:24 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun Dec 21 13:54:48 2008 Subject: [Haskell-cafe] Re: Is this related to monomorphism restriction? In-Reply-To: References: <4cf038ee0812201556m7fe8d3dfnd4a36bc8490caa3e@mail.gmail.com> Message-ID: <2f9b2d30812211102y66c900c2wacc5b0ce76f033b0@mail.gmail.com> You have a few options. In Haskell98 (no extensions): a () = (f,f) g () = fst (a ()) -- alternatively g x = fst (a ()) x Here you make it explicit that "a" and "g" are functions; the monomorphism restriction is there to stop things that look like values (and therefore you expect to only get evaluated once) from being functions (which get evaluated every time they are used). Alternatively, you are allowed to tell the compiler "This value should be polymorphic" with a type signature: a :: TestClass a => (a -> Integer, a -> Integer) a = (f,f) g :: TestClass a => a -> Integer g = fst a The non-haskell98 solution: {-# LANGUAGE NoMonomorphismRestriction #-} But beware that it is really there to protect you; code that uses g will compile to something very similar to the first operation I showed, re-evaluating "fst a" and doing dictionary selection at every use of g. -- ryan On Sun, Dec 21, 2008 at 9:21 AM, Maur??cio wrote: >>> Why isn't the last line of this code allowed? >>> f :: (TestClass a) => a -> Integer >>> f = const 1 >>> a = (f,f) >>> g = fst a >>> The only thing I can think about is monomorphism >>> restriction, but it's allowed (...) > >> (...) The reason is that a has type >> a :: (TestClass a, TestClass b) => (a,b) >> and then when we take 'fst' of this value (as in g) we get > >> g :: (TestClass a, TestClass b) => a >> which is an ambiguous type, (...) > > Is there some version (i.e., set of extensions) of > Haskell where this would be allowed? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From miguelimo38 at yandex.ru Sun Dec 21 14:04:00 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sun Dec 21 13:56:33 2008 Subject: [Haskell-cafe] Re: Time for a new logo? In-Reply-To: <0F043848-06B3-47FD-AD01-69CF09E42C5E@ece.cmu.edu> References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <6E8D2069C08AA84A83D336E996AE4C6702339A3233@mse17be1.mse17.exchange.ms> <0F043848-06B3-47FD-AD01-69CF09E42C5E@ece.cmu.edu> Message-ID: <9AFD5EFE-24B0-4508-A487-82AD62AE515E@yandex.ru> BTW, in Russian the character "X" (pronounced a bit like English "H") is the first letter in "Haskell". On 21 Dec 2008, at 21:48, Brandon S. Allbery KF8NH wrote: > On 2008 Dec 17, at 8:42, Darrin Thompson wrote: >> X monad could have a variant of this logo too. >X= (That's how I >> originally thought of it, just was too lazy to post it anywhere. >> Sorry >> about that.) > > > Or just a lambda with an extra contrasting stroke to make an X (?' > very roughly, if you have the right font). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university > KF8NH > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From byorgey at seas.upenn.edu Sun Dec 21 14:17:04 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sun Dec 21 14:09:30 2008 Subject: [Haskell-cafe] ANN: Data.List.Split Message-ID: <20081221191704.GA24992@seas.upenn.edu> I am pleased to announce the release of Data.List.Split, which provides a wide range of strategies and a unified combinator framework for splitting lists with respect to some sort of delimiter. It strives to be flexible yet simple. If you've ever wished there was a simple 'split' function you could grab from Data.List, this is the package for you---no matter which of the seventeen* slightly different ways to split a list you actually need! Just use one of the prepackaged splitting strategies, or build your own with the combinator library. Get it from Hackage: cabal install split http://hackage.haskell.org/cgi-bin/hackage-scripts/package/split Get the source: darcs get http://code.haskell.org/~byorgey/code/split Get excited: http://byorgey.wordpress.com/2008/12/21/datalistsplit/ -Brent * Actual number may vary. From iavor.diatchki at gmail.com Sun Dec 21 14:25:06 2008 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Sun Dec 21 14:17:29 2008 Subject: [Haskell-cafe] Re: Is this related to monomorphism restriction? In-Reply-To: References: <4cf038ee0812201556m7fe8d3dfnd4a36bc8490caa3e@mail.gmail.com> Message-ID: <5ab17e790812211125x44f9c98el37b6bca5477ec66b@mail.gmail.com> Hello, You can work around the monomorphism restriction with extensions but to fix the ambiguity in your program that Reiner pointed out you'll have to change the program to specify how you'd like to instantiate "a". here are all the types once again: f :: (TestClass a) => a -> Integer f = const 1 a :: (TestClass a, TestClass b) => (a -> Integer, b -> Integer) a = (f,f) g :: (TestClass a, TestClass b) => a -> Integer -- ambiguous g = fst a Note that the type of 'g' to the right of '=>' does not mention 'b'. This means that the type of 'g' is ambiguos because the type checker does not know how to pick a type for 'b'. To fix that, you could: 1. Give 'a' a less general type, for example: a :: (TestClass a) => (a -> Integer, a -> Integer) 2. Write a type signature on the use of 'a': g :: TestClass a => a -> Integer g = fst (a :: (a -> Integer, a -> Integer)) Here we are using another GHC extension called "scoped type variables" to associate the "a" in the type signature of "g" with the "a" in the type annotation for the value "a". Hope that this helps, Iavor On Sun, Dec 21, 2008 at 9:21 AM, Maur??cio wrote: >>> Why isn't the last line of this code allowed? >>> f :: (TestClass a) => a -> Integer >>> f = const 1 >>> a = (f,f) >>> g = fst a >>> The only thing I can think about is monomorphism >>> restriction, but it's allowed (...) > >> (...) The reason is that a has type >> a :: (TestClass a, TestClass b) => (a,b) >> and then when we take 'fst' of this value (as in g) we get > >> g :: (TestClass a, TestClass b) => a >> which is an ambiguous type, (...) > > Is there some version (i.e., set of extensions) of > Haskell where this would be allowed? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From brianchina60221 at gmail.com Sun Dec 21 14:30:30 2008 From: brianchina60221 at gmail.com (brian) Date: Sun Dec 21 14:22:53 2008 Subject: [Haskell-cafe] Removing/Uninstalling cabal packages ? In-Reply-To: References: Message-ID: <22f6a8f70812211130kb4c27a6g423336a195788f8a@mail.gmail.com> On Sun, Dec 21, 2008 at 12:12 PM, Laurent Giroud wrote: > I have been doing a few experiments with cabal packages lately and I wish to > uninstall these to return to a cleaner package base. However, there doesn't > seem to be a "cabal uninstall" command and reading the documentation at > http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html does not tell > much about how to do that manually. I think you want 'ghc-pkg list' and 'ghc-pkg unregister'. From lrpalmer at gmail.com Sun Dec 21 14:45:12 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Dec 21 14:37:37 2008 Subject: [Haskell-cafe] Re: Is this related to monomorphism restriction? In-Reply-To: <5ab17e790812211125x44f9c98el37b6bca5477ec66b@mail.gmail.com> References: <4cf038ee0812201556m7fe8d3dfnd4a36bc8490caa3e@mail.gmail.com> <5ab17e790812211125x44f9c98el37b6bca5477ec66b@mail.gmail.com> Message-ID: <7ca3f0160812211145v131c90ccsd84d5d51421af91c@mail.gmail.com> 2008/12/21 Iavor Diatchki > > > g :: TestClass a => a -> Integer > g = fst (a :: (a -> Integer, a -> Integer)) Which I believe needs to be written: g :: forall a. TestClass a => a -> Integer g = fst (a :: (a -> Integer, a -> Integer)) > > > Here we are using another GHC extension called "scoped type variables" > to associate the "a" in the type signature of "g" with the "a" in the > type annotation for the value "a". > > Hope that this helps, > Iavor > > > > > On Sun, Dec 21, 2008 at 9:21 AM, Maur??cio > wrote: > >>> Why isn't the last line of this code allowed? > >>> f :: (TestClass a) => a -> Integer > >>> f = const 1 > >>> a = (f,f) > >>> g = fst a > >>> The only thing I can think about is monomorphism > >>> restriction, but it's allowed (...) > > > >> (...) The reason is that a has type > >> a :: (TestClass a, TestClass b) => (a,b) > >> and then when we take 'fst' of this value (as in g) we get > > > >> g :: (TestClass a, TestClass b) => a > >> which is an ambiguous type, (...) > > > > Is there some version (i.e., set of extensions) of > > Haskell where this would be allowed? > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/3154eb05/attachment.htm From paul at cogito.org.uk Sun Dec 21 15:07:10 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Sun Dec 21 14:59:37 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise Message-ID: <494EA1EE.1010606@cogito.org.uk> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/748eb018/attachment.htm From allbery at ece.cmu.edu Sun Dec 21 15:27:52 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Dec 21 15:20:19 2008 Subject: intimidating terminology (was: Re: [Haskell-cafe] Time for a new logo?) In-Reply-To: References: <20081214211504.GO27904@scytale.galois.com> <4946D6EF.7040106@btinternet.com> <20081216121217.105ae7d7.Malcolm.Wallace@cs.york.ac.uk> <49480E56.6000506@btinternet.com> <20081217140137.GB10904@mithrandi.net> <49497CB2.2030507@btinternet.com> <494B05A1.4070306@freegeek.org> Message-ID: On 2008 Dec 19, at 4:13, Lennart Augustsson wrote: > When accurate names for Haskell concepts already exist we should use > them (as we have tried in the past). There has been too much > invention of misleading terminology in computing already. If some > people can't handle things having the right names, well, maybe they > should try another language. (What would happen if we used the new > name principle, e.g., in cooking? "Oh, cinnamon is a difficult name, > I'll call it tangy spice instead.") Cinnamon's already got an accuracy problem anyway: what most people in the US call cinnamon is actually cassia. -- 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 dons at galois.com Sun Dec 21 15:41:40 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 21 15:33:56 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <494EA1EE.1010606@cogito.org.uk> References: <494EA1EE.1010606@cogito.org.uk> Message-ID: <20081221204140.GB25156@scytale.galois.com> Wonderful, Paul. Could you add your list of adjectives to the wiki page. Note that the initial "deadline" was Dec 31, after which time we can filter out dupes and narrow down the logos to about 5 or so different directions to have a vote on. Anything you can do to help direct or improve quality is welcome! -- Don paul: > A [1]call has gone out for a new logo for Haskell. Candidates (including > a [2]couple of [3]mine) are accumulating [4]here. There has also been a > long thread on the Haskell Cafe mailing list. > > I've lived through a couple of corporate rebranding exercises in my time, > and I've read about some others. They follow a pattern: > > 1. Management decide that the organisation needs a makeover to change > public perception. A new corporate "look and feel" is part of this, > and a new logo is therefore required. The rest of the makeover may be > deep or shallow; that doesn't affect the rest of this story. > 2. The new branding is released with as much fanfare as possible. Press > releases are released. Staff are given briefings about the > significance of the whole exercise and the bold new future that it > symbolises. > 3. The staff universally agree that the new logo is not a patch on the > old one. The old one was a much loved friend; it stood for something; > people have spent years working for it. The new one is obviously a > piece of cheap gimcrackery munged up by an overpaid consultancy hired > by senior managers who mistake image for substance. A ten year-old > with an Etch-a-Sketch could have done better. > 4. Over time the new logo blends in and becomes part of the scenery. > Years pass. Go to stage 1 and repeat. > > This suggests that the current effort to find a new logo for Haskell needs > to go back to the basics. Its no good expecting consensus on one of the > suggestions because there are too many options and everyone has their > favourite. Nothing will attract a majority of the community. > > Furthermore I think that (just like programmers everywhere) we have dived > into development before deciding what the requirements are. This is > reflected in the mailing list discussion, where two broad positions seem > to be emerging. > > * On one side we have what I think of as the "Vulcans". This group sees > Haskell as abstract and difficult, and believes that the logo should > reflect these qualities. They want mathematical symbols to dominate > the design. > * On the other side we have the "Warm Fuzzies". They want Haskell to be > perceived as accessible and welcoming, and so want a logo featuring > something warm and friendly. > > A paradox of the Haskell world is that, while the language is Vulcan, the > community around it is dominated by Warm Fuzziness. Clearly the two are > not mutually exclusive. > > A rebranding exercise needs to start with a short list of adjectives that > the brand is to represent, and I think that the Haskell community needs to > decide this before it fires up Inkscape. To that end, here are a sample > of adjectives in alphabetical order: > > abstract, academic, accessible, accurate, adventurous, business-like, > communal, complicated, dangerous, different, easy, exciting, familiar, > friendly, fun, fuzzy, hard, interesting, inventive, precise, productive, > profitable, reliable, revolutionary, safe, simple, strange, supportive, > warm, welcoming. > > What are the top three adjectives we want to project? Once we have > decided that, we can write a brief for the Haskell logo. > > Note that the selected adjectives need not be related. In fact they may > be partly contradictory. I've already noted that the language is Vulcan > whereas the community is Warm and Friendly. So they might reasonably be > the three adjectives (though I wouldn't take "Vulcan" too literally). The > challenge will then be for the graphical work to project these qualities, > even if they seem incompatible. > > References > > Visible links > 1. http://www.haskell.org/pipermail/haskell-cafe/2008-December/051836.html > 2. http://www.haskell.org/haskellwiki/Image:Haskell-logo-revolution.png > 3. http://www.haskell.org/sitewiki/images/f/fd/Ouroborous-oval.png > 4. http://www.haskell.org/haskellwiki/Haskell_logos/New_logo_ideas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From manlio_perillo at libero.it Sun Dec 21 16:07:50 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Dec 21 16:00:34 2008 Subject: [Haskell-cafe] GHC libraries documentation and links to source files Message-ID: <494EB026.2030103@libero.it> Hi. I have noted that recent versions of the GHC libraries documentation, no longer have links to the source code. What is the reason? I find it very useful. Thanks Manlio Perillo From donnie at darthik.com Sun Dec 21 16:11:09 2008 From: donnie at darthik.com (Donnie Jones) Date: Sun Dec 21 16:03:33 2008 Subject: [Haskell-cafe] GHC libraries documentation and links to source files In-Reply-To: <494EB026.2030103@libero.it> References: <494EB026.2030103@libero.it> Message-ID: Hello Manilo and Haskell-cafe, On Sun, Dec 21, 2008 at 4:07 PM, Manlio Perillo wrote: > Hi. > > I have noted that recent versions of the GHC libraries documentation, no > longer have links to the source code. > > What is the reason? > I find it very useful. > > I would like to suggest that all Haskell libraries generate documentation with "view source" links. Like Manilo, I also find it very useful. Thank you. __ Donnie Jones -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/bf5eb42c/attachment.htm From sylvan at student.chalmers.se Sun Dec 21 16:19:47 2008 From: sylvan at student.chalmers.se (Sebastian Sylvan) Date: Sun Dec 21 16:12:10 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <494EA1EE.1010606@cogito.org.uk> References: <494EA1EE.1010606@cogito.org.uk> Message-ID: <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> 2008/12/21 Paul Johnson > > > > This suggests that the current effort to find a new logo for Haskell needs > to go back to the basics. Its no good expecting consensus on one of the > suggestions because there are too many options and everyone has their > favourite. Nothing will attract a majority of the community. > I agree with this, which I why I would propose using Condorcet-voting. Personally I find the current logo horrendous. I think it's ugly and intimidating at the same time. I don't really care too much which one of the proposals should win, just so long as I can weed out some of the ones I really hate. Condorcet voting will pick a good compromise, where someone like me could just put all the acceptable ones at shared #1, and all the ones I dislike at #2., and someone with stronger opinions could flesh it out some more. The point being that the "least disliked" logo wins out. Maybe nobody will be happy, but hopefully most people won't be deeply unhappy with it. It would be a shame if there's lots of votes that are spread out over a large group of fairly similar logos that are good, and then a crappy one wins out with 6% of the vote because there weren't any others like it so the votes for that "style" weren't spread out over multiple entries. Wikipedia: http://en.wikipedia.org/wiki/Condorcet_voting -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/6747b493/attachment.htm From dons at galois.com Sun Dec 21 16:23:33 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 21 16:16:05 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> Message-ID: <20081221212333.GB25249@scytale.galois.com> Would you be willing to set up a little online voting system (or do you know of one) so we can implement this? Assume there'll be < 10 candidates. -- Don sylvan: > 2008/12/21 Paul Johnson <[1]paul@cogito.org.uk> > > This suggests that the current effort to find a new logo for Haskell > needs to go back to the basics. Its no good expecting consensus on one > of the suggestions because there are too many options and everyone has > their favourite. Nothing will attract a majority of the community. > > I agree with this, which I why I would propose using Condorcet-voting. > Personally I find the current logo horrendous. I think it's ugly and > intimidating at the same time. I don't really care too much which one of > the proposals should win, just so long as I can weed out some of the ones > I really hate. > Condorcet voting will pick a good compromise, where someone like me could > just put all the acceptable ones at shared #1, and all the ones I dislike > at #2., and someone with stronger opinions could flesh it out some more. > The point being that the "least disliked" logo wins out. Maybe nobody will > be happy, but hopefully most people won't be deeply unhappy with it. > It would be a shame if there's lots of votes that are spread out over a > large group of fairly similar logos that are good, and then a crappy one > wins out with 6% of the vote because there weren't any others like it so > the votes for that "style" weren't spread out over multiple entries. > Wikipedia: > [2]http://en.wikipedia.org/wiki/Condorcet_voting > > -- > Sebastian Sylvan > +44(0)7857-300802 > UIN: 44640862 > > References > > Visible links > 1. mailto:paul@cogito.org.uk > 2. http://en.wikipedia.org/wiki/Condorcet_voting > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From sylvan at student.chalmers.se Sun Dec 21 16:26:23 2008 From: sylvan at student.chalmers.se (Sebastian Sylvan) Date: Sun Dec 21 16:18:47 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <20081221212333.GB25249@scytale.galois.com> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> <20081221212333.GB25249@scytale.galois.com> Message-ID: <3d96ac180812211326s46953569wdce3c65f76abeb42@mail.gmail.com> I am very shortly travelling abroad for several weeks and will not have (reliable access to) a computer, but isn't this a task for one of the haskell web-apps people (HSP, HAppS, Turbinado, etc.) to show us once and for all why *their* library is better than the competition? :-) On Sun, Dec 21, 2008 at 9:23 PM, Don Stewart wrote: > Would you be willing to set up a little online voting system (or do you > know of one) so we can implement this? > > Assume there'll be < 10 candidates. > > -- Don > > sylvan: > > 2008/12/21 Paul Johnson <[1]paul@cogito.org.uk> > > > > This suggests that the current effort to find a new logo for Haskell > > needs to go back to the basics. Its no good expecting consensus on > one > > of the suggestions because there are too many options and everyone > has > > their favourite. Nothing will attract a majority of the community. > > > > I agree with this, which I why I would propose using Condorcet-voting. > > Personally I find the current logo horrendous. I think it's ugly and > > intimidating at the same time. I don't really care too much which one > of > > the proposals should win, just so long as I can weed out some of the > ones > > I really hate. > > Condorcet voting will pick a good compromise, where someone like me > could > > just put all the acceptable ones at shared #1, and all the ones I > dislike > > at #2., and someone with stronger opinions could flesh it out some > more. > > The point being that the "least disliked" logo wins out. Maybe nobody > will > > be happy, but hopefully most people won't be deeply unhappy with it. > > It would be a shame if there's lots of votes that are spread out over > a > > large group of fairly similar logos that are good, and then a crappy > one > > wins out with 6% of the vote because there weren't any others like it > so > > the votes for that "style" weren't spread out over multiple entries. > > Wikipedia: > > [2]http://en.wikipedia.org/wiki/Condorcet_voting > > > > -- > > Sebastian Sylvan > > +44(0)7857-300802 > > UIN: 44640862 > > > > References > > > > Visible links > > 1. mailto:paul@cogito.org.uk > > 2. http://en.wikipedia.org/wiki/Condorcet_voting > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/c8d9aa91/attachment.htm From kili at outback.escape.de Sun Dec 21 16:36:02 2008 From: kili at outback.escape.de (Matthias Kilian) Date: Sun Dec 21 16:29:08 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <20081221212333.GB25249@scytale.galois.com> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> <20081221212333.GB25249@scytale.galois.com> Message-ID: <20081221213602.GB32096@petunia.outback.escape.de> On Sun, Dec 21, 2008 at 01:23:33PM -0800, Don Stewart wrote: > Would you be willing to set up a little online voting system (or do you > know of one) so we can implement this? > > Assume there'll be < 10 candidates. What about www.doodle.com? Ciao, Kili From dons at galois.com Sun Dec 21 16:41:47 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 21 16:34:00 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <20081221213602.GB32096@petunia.outback.escape.de> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> <20081221212333.GB25249@scytale.galois.com> <20081221213602.GB32096@petunia.outback.escape.de> Message-ID: <20081221214147.GC25249@scytale.galois.com> kili: > On Sun, Dec 21, 2008 at 01:23:33PM -0800, Don Stewart wrote: > > Would you be willing to set up a little online voting system (or do you > > know of one) so we can implement this? > > > > Assume there'll be < 10 candidates. > > What about www.doodle.com? That looks like it might be an option, embedded in a page with the 10 candidates. Thanks! Don From redcom at fedoms.com Sun Dec 21 16:43:48 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Dec 21 16:36:28 2008 Subject: [Haskell-cafe] Threads with high CPU usage Message-ID: Hi, in an application of mine I start a long-running operation in a thread via forkIO so that the UI process doesn't get blocked. It just so happens, that the long-running process also takes the CPU to nearly 100% while it runs. During that time the run-time system does *not* switch back and forth between the UI-process and the long-running task, it seems that the UI process only gets woken up *after* the high CPU thread finishes completely. To the effect of course that it makes no difference at all to the UIs responsiveness whether I use forkIO or not. The long running process is pretty atomic, it's a single query to the database which takes up to a minute to complete so I don't see a chance to squeeze a "mainIteration" in there. What can I do? G?nther From dons at galois.com Sun Dec 21 16:47:40 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 21 16:40:03 2008 Subject: [Haskell-cafe] Threads with high CPU usage In-Reply-To: References: Message-ID: <20081221214740.GD25249@scytale.galois.com> redcom: > Hi, > > in an application of mine I start a long-running operation in a thread via > forkIO so that the UI process doesn't get blocked. > It just so happens, that the long-running process also takes the CPU to > nearly 100% while it runs. > > During that time the run-time system does *not* switch back and forth > between the UI-process and the long-running task, it seems that the UI > process only gets woken up *after* the high CPU thread finishes completely. > > To the effect of course that it makes no difference at all to the UIs > responsiveness whether I use forkIO or not. > > The long running process is pretty atomic, it's a single query to the > database which takes up to a minute to complete so I don't see a chance to > squeeze a "mainIteration" in there. > How are you compiling this code (-O -threaded ?) and what does the forkIO'd thread do? Does it allocate? Would increasing the runtime scheduling ticks help? (Perhaps , if the UI is mostly sleeping). -- Don From allbery at ece.cmu.edu Sun Dec 21 17:09:32 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Dec 21 17:02:05 2008 Subject: [Haskell-cafe] Threads with high CPU usage In-Reply-To: <20081221214740.GD25249@scytale.galois.com> References: <20081221214740.GD25249@scytale.galois.com> Message-ID: <7026FDD4-11AC-41FB-8B27-9B0D1CCB3AFC@ece.cmu.edu> On 2008 Dec 21, at 16:47, Don Stewart wrote: > redcom: >> The long running process is pretty atomic, it's a single query to the >> database which takes up to a minute to complete so I don't see a >> chance to >> squeeze a "mainIteration" in there. >> > > How are you compiling this code (-O -threaded ?) and what does the > forkIO'd thread do? Does it allocate? Sounds to me like it's making FFI calls to a database library. I smell bound threads, especially if the UI also makes FFI calls. -- 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 mads_lindstroem at yahoo.dk Sun Dec 21 17:16:22 2008 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Sun Dec 21 17:12:18 2008 Subject: [Haskell-cafe] Threads with high CPU usage In-Reply-To: References: Message-ID: <1229897782.4495.7.camel@localhost.localdomain> Hi G?nter G?nther Schmidt wrote: > Hi, > > in an application of mine I start a long-running operation in a thread via > forkIO so that the UI process doesn't get blocked. > It just so happens, that the long-running process also takes the CPU to > nearly 100% while it runs. > > During that time the run-time system does *not* switch back and forth > between the UI-process and the long-running task, it seems that the UI > process only gets woken up *after* the high CPU thread finishes completely. > > To the effect of course that it makes no difference at all to the UIs > responsiveness whether I use forkIO or not. > > The long running process is pretty atomic, it's a single query to the > database which takes up to a minute to complete so I don't see a chance to > squeeze a "mainIteration" in there. It could be the database library, as it may use unsafe foreign calls. Unsafe foreign calls blocks all other threads, even if you compile with the -threaded option. See http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#4 . I cannot claim to know how all Haskell database libraries are implemented, but at least some of them use unsafe foreign calls. So which database library is you using? > > What can I do? If the problem has to do with unsafe foreign calls, then you can implement the database calls in a separate process. Not the easiest options, but I can think of no other. > > G?nther > /Mads Lindstr?m From redcom at fedoms.com Sun Dec 21 17:30:40 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Dec 21 17:23:24 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage References: <1229897782.4495.7.camel@localhost.localdomain> Message-ID: Hi Mads, I'm using HDBC with sqlite3 G?nther From bugfact at gmail.com Sun Dec 21 17:32:24 2008 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Dec 21 17:24:48 2008 Subject: [Haskell-cafe] Threads with high CPU usage In-Reply-To: <1229897782.4495.7.camel@localhost.localdomain> References: <1229897782.4495.7.camel@localhost.localdomain> Message-ID: Would forkOS instead of forkIO help in this case? On Sun, Dec 21, 2008 at 11:16 PM, Mads Lindstr?m wrote: > Hi G?nter > > G?nther Schmidt wrote: > > Hi, > > > > in an application of mine I start a long-running operation in a thread > via > > forkIO so that the UI process doesn't get blocked. > > It just so happens, that the long-running process also takes the CPU to > > nearly 100% while it runs. > > > > During that time the run-time system does *not* switch back and forth > > between the UI-process and the long-running task, it seems that the UI > > process only gets woken up *after* the high CPU thread finishes > completely. > > > > To the effect of course that it makes no difference at all to the UIs > > responsiveness whether I use forkIO or not. > > > > The long running process is pretty atomic, it's a single query to the > > database which takes up to a minute to complete so I don't see a chance > to > > squeeze a "mainIteration" in there. > > It could be the database library, as it may use unsafe foreign calls. > Unsafe foreign calls blocks all other threads, even if you compile with > the -threaded option. See > > http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#4. > > I cannot claim to know how all Haskell database libraries are > implemented, but at least some of them use unsafe foreign calls. So > which database library is you using? > > > > > What can I do? > > If the problem has to do with unsafe foreign calls, then you can > implement the database calls in a separate process. Not the easiest > options, but I can think of no other. > > > > > G?nther > > > > /Mads Lindstr?m > > > > _______________________________________________ > 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/20081221/9ad2a90c/attachment.htm From mads_lindstroem at yahoo.dk Sun Dec 21 17:35:06 2008 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Sun Dec 21 17:37:41 2008 Subject: [Haskell-cafe] Threads with high CPU usage In-Reply-To: References: <1229897782.4495.7.camel@localhost.localdomain> Message-ID: <1229898906.4495.9.camel@localhost.localdomain> Hi Peter, Peter Verswyvelen wrote: > Would forkOS instead of forkIO help in this case? No, according to http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#v%3AforkOS : "Using forkOS instead of forkIO makes no difference at all to the scheduling behaviour of the Haskell runtime system. It is a common misconception that you need to use forkOS instead of forkIO to avoid blocking all the Haskell threads when making a foreign call; this isn't the case. To allow foreign calls to be made without blocking all the Haskell threads (with GHC), it is only necessary to use the -threaded option when linking your program, and to make sure the foreign import is not marked unsafe." /Mads > > On Sun, Dec 21, 2008 at 11:16 PM, Mads Lindstr?m > wrote: > Hi G?nter > > G?nther Schmidt wrote: > > Hi, > > > > in an application of mine I start a long-running operation > in a thread via > > forkIO so that the UI process doesn't get blocked. > > It just so happens, that the long-running process also takes > the CPU to > > nearly 100% while it runs. > > > > During that time the run-time system does *not* switch back > and forth > > between the UI-process and the long-running task, it seems > that the UI > > process only gets woken up *after* the high CPU thread > finishes completely. > > > > To the effect of course that it makes no difference at all > to the UIs > > responsiveness whether I use forkIO or not. > > > > The long running process is pretty atomic, it's a single > query to the > > database which takes up to a minute to complete so I don't > see a chance to > > squeeze a "mainIteration" in there. > > > It could be the database library, as it may use unsafe foreign > calls. > Unsafe foreign calls blocks all other threads, even if you > compile with > the -threaded option. See > http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#4 . > > I cannot claim to know how all Haskell database libraries are > implemented, but at least some of them use unsafe foreign > calls. So > which database library is you using? > > > > > What can I do? > > If the problem has to do with unsafe foreign calls, then you > can > implement the database calls in a separate process. Not the > easiest > options, but I can think of no other. > > > > > G?nther > > > > /Mads Lindstr?m > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From mads_lindstroem at yahoo.dk Sun Dec 21 17:39:51 2008 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Sun Dec 21 17:38:53 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <1229897782.4495.7.camel@localhost.localdomain> Message-ID: <1229899191.4495.13.camel@localhost.localdomain> Hi G?nther, > Hi Mads, > > I'm using HDBC with sqlite3 Looking at http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Connection.hs and http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Statement.hsc you can see that HDBC-sqlite's foreign calls are indeed marked unsafe. /Mads > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From redcom at fedoms.com Sun Dec 21 17:57:22 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Dec 21 17:49:51 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <1229899191.4495.13.camel@localhost.localdomain> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> Message-ID: Hi Mads, I just noticed that too. I had been wondering why this problem does not occur with the sample app from RWH eventhough I was employing the same technics as they did. It just occured to me that all the DB interactions in their app are fairly short and thus the problem never becomes apparent. Thanks everyone, I was going crazy here, couldn't figure out what I was doing wrong. Would anyone happen to know of a "safe" alternative to HDBC? G?nther Am 21.12.2008, 23:39 Uhr, schrieb Mads Lindstr?m : > Hi G?nther, > >> Hi Mads, >> >> I'm using HDBC with sqlite3 > > Looking at > http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Connection.hs > and > http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Statement.hsc > you can see that HDBC-sqlite's foreign calls are indeed marked unsafe. > > /Mads > >> >> G?nther >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Sun Dec 21 18:07:12 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 21 17:59:48 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> Message-ID: <20081221230712.GE25249@scytale.galois.com> redcom: > Hi Mads, > > I just noticed that too. > > I had been wondering why this problem does not occur with the sample app > from RWH eventhough I was employing the same technics as they did. > > It just occured to me that all the DB interactions in their app are fairly > short and thus the problem never becomes apparent. > > Thanks everyone, I was going crazy here, couldn't figure out what I was > doing wrong. > > Would anyone happen to know of a "safe" alternative to HDBC? Modify the 'unsafe' inports to be 'safe'? I don't think HDBC is going to call back in, so should be fine. John? That said, we use Takusen or sqlite3 at work, without troubles. -- Don From redcom at fedoms.com Sun Dec 21 18:24:20 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Dec 21 18:16:48 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <20081221230712.GE25249@scytale.galois.com> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> Message-ID: Hi Don, > > Modify the 'unsafe' inports to be 'safe'? I don't think HDBC is going to > call back in, so should be fine. John? Sorry, total noob here, could you be more specific? G?nther > > That said, we use Takusen or sqlite3 at work, without troubles. I might also check into that. > > -- Don From dave at zednenem.com Sun Dec 21 18:47:41 2008 From: dave at zednenem.com (David Menendez) Date: Sun Dec 21 18:40:07 2008 Subject: [Haskell-cafe] Comparing on multiple criteria In-Reply-To: <71B0F62F-5B5B-4F57-B280-23F4CF2E917E@alum.mit.edu> References: <494E4A07.7040807@van.steenbergen.nl> <71B0F62F-5B5B-4F57-B280-23F4CF2E917E@alum.mit.edu> Message-ID: <49a77b7a0812211547xffadfd9ue25c04cea919d7a7@mail.gmail.com> On Sun, Dec 21, 2008 at 11:20 AM, Jan-Willem Maessen wrote: > On Dec 21, 2008, at 8:52 AM, Martijn van Steenbergen wrote: > >> Hello all, >> >> Data.Ord has a handy function called comparing, and its documentation >> shows an example of its use. >> >> But what if you want to sort a list of values based on multiple criteria? >> It turns out there is a neat way to do this: >> >> compareTuple = mconcat [comparing fst, comparing snd] >> >> The default Monoid instances for Ordering and functions work exactly as >> required here. (Thanks to vixey in #haskell for the hint to look at >> monoids!) > > Indeed, this is great to know. I can't help but notice that there is no > documentation of any kind at all for the Monoid instance of Ordering; how > were we supposed to know this behavior existed in the first place, except by > hunting down the source code for the instance declaration? This is a great example of why it's a bad idea to introduce new functionality with a Monoid instance. Even if you know the instance exists, mappend is so general that it's difficult or impossible to predict what it will do at a given type. There should be an explicit function for combining Ordering values lexicographically, with a note in the documentation saying that it's the basis of the Monoid instance. -- Dave Menendez From andre at digirati.com.br Sun Dec 21 19:14:00 2008 From: andre at digirati.com.br (Andre Nathan) Date: Sun Dec 21 19:05:28 2008 Subject: [Haskell-cafe] Trouble with the ST monad Message-ID: <1229904840.6245.5.camel@homesick> Hello, I'm trying to write a function that would take an STArray and and shuffle its elements. I'm having trouble with the ST monad, though, and couldn't find out how fix this issue. The problem happens when I use runST to extract the shuffled array from the ST monad. I'm getting the following error: Inferred type is less polymorphic than expected Quantified type variable `s' is mentioned in the environment: a :: STArray s Int a The full code is at http://hpaste.org/13240#a1 Any help would be appreciated. Thanks, Andre From ajb at spamcop.net Sun Dec 21 19:42:15 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Sun Dec 21 19:34:31 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> Message-ID: <20081221194215.o3c3x76zeo4gkggk-nwo@webmail.spamcop.net> G'day all. Quoting Sebastian Sylvan : > Personally I find the current logo horrendous. I think it's ugly and > intimidating at the same time. I don't really care too much which one of the > proposals should win, just so long as I can weed out some of the ones I > really hate. I guess this is one difference between the Haskell rebranding exercise and other corporate rebranding exercises: Nobody especially likes the current logo. (Disclaimer: It would be fair to say that there are some who don't hate it as much as Sebastian, but nobody really "likes" it.) Cheers, Andrew Bromage From g9ks157k at acme.softbase.org Sun Dec 21 19:45:38 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sun Dec 21 19:38:05 2008 Subject: [Haskell-cafe] Records and associated types In-Reply-To: <20081211210424.GA25465@taruti.net> References: <20081211210424.GA25465@taruti.net> Message-ID: <200812220145.38284.g9ks157k@acme.softbase.org> Am Donnerstag, 11. Dezember 2008 22:04 schrieb Taru Karttunen: > Hello > > What is the correct way to transform code that uses record selection > with TypeEq (like HList) to associated types? Hello Taru, you might want to look at and its follow-ups. Best wishes, Wolfgang From ryani.spam at gmail.com Sun Dec 21 19:47:01 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun Dec 21 19:39:24 2008 Subject: [Haskell-cafe] Trouble with the ST monad In-Reply-To: <1229904840.6245.5.camel@homesick> References: <1229904840.6245.5.camel@homesick> Message-ID: <2f9b2d30812211647y46cfcbb5xf87ff5923f320920@mail.gmail.com> The problem is that you are trying to return a mutable array out of an ST computation. This lets the "mutability" of the computation escape. That's what the "s" type variable is for; without it, runST is just unsafePerformIO. To solve your problem, you need to eliminate any references to the state from the output of runST. I suggest looking into the function "freezeSTArray": >From http://haskell.org/ghc/docs/latest/html/libraries/base/GHC-Arr.html#v:freezeSTArray freezeSTArray :: Ix i => STArray s i e -> ST s (Array i e) (See my annotation at http://hpaste.org/13240#a2) This allows you to remove any reference to the state from the array computation. Alternatively, if you want this to be part of a larger mutable computation, you can return the result in ST; this is what the version of shuffle you have in the paste does. -- ryan On Sun, Dec 21, 2008 at 4:14 PM, Andre Nathan wrote: > Hello, > > I'm trying to write a function that would take an STArray and and > shuffle its elements. I'm having trouble with the ST monad, though, and > couldn't find out how fix this issue. > > The problem happens when I use runST to extract the shuffled array from > the ST monad. I'm getting the following error: > > Inferred type is less polymorphic than expected > Quantified type variable `s' is mentioned in the environment: > a :: STArray s Int a > > The full code is at > > http://hpaste.org/13240#a1 > > Any help would be appreciated. > > Thanks, > Andre > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From sanzhiyan at gmail.com Sun Dec 21 19:47:19 2008 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Sun Dec 21 19:39:45 2008 Subject: [Haskell-cafe] Threads with high CPU usage In-Reply-To: References: Message-ID: <8625cd9c0812211647r4e3f7455k593df0fcda3ef34e@mail.gmail.com> Tried running the program with +RTS -Nn where n = 2 or more? that should use more OS threads On Sun, Dec 21, 2008 at 10:43 PM, G?nther Schmidt wrote: > Hi, > > in an application of mine I start a long-running operation in a thread via > forkIO so that the UI process doesn't get blocked. > It just so happens, that the long-running process also takes the CPU to > nearly 100% while it runs. > > During that time the run-time system does *not* switch back and forth > between the UI-process and the long-running task, it seems that the UI > process only gets woken up *after* the high CPU thread finishes completely. > > To the effect of course that it makes no difference at all to the UIs > responsiveness whether I use forkIO or not. > > The long running process is pretty atomic, it's a single query to the > database which takes up to a minute to complete so I don't see a chance to > squeeze a "mainIteration" in there. > > What can I do? > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/054c6df7/attachment.htm From himself at poczta.nom.pl Sun Dec 21 20:03:40 2008 From: himself at poczta.nom.pl (Andrzej Jaworski) Date: Sun Dec 21 19:56:10 2008 Subject: [Haskell-cafe] A hell of a question Message-ID: <542709579B684DFEB328B6E788464AA1@bzdryk> I just want to say Hello to let you know that there are some serious entities watching you besides monads and FBI:-) There has been a hell of a discussion recently about logos, languages and religion and I want to add to this. First let me disassociate Haskell from Taoism which to may taste has left us in an unhealthy climate. It suffices to say that Taoism is a school of clever trics and cute aphorisms but without the slightest attempt to explain or generalize let alone produce an abstract idea or a system. That is why its wisdom is non transferable in spite of majority of humans desending from it. Haskell on the contrary is a minority school that implements abstract ideas for problem solving in the most transferable way to date, so that other languages look into it for their share. But don't worry, thay will choke becouse it is them who practice Taoizm. Playing too many tricks will eventually trick them, even if some are powerful enough to brainwash dicent professors to preach interoperability or the like. Every viable complexity needs a single underlying concept to survive, including you and the universe. Microsoft and the like excluding;-) Haskell has all that: consistency, transparency and self-contained concept. However Haskell is also somehow asynchronic with the Bible as it is condemned to perpetual purity only to be saved from it via monads, which according to Spinoza "are arranged by God in a perfect order which ascends to God, the supreme monad!!!". Thus we can look at Haskell's purity as a kind of harmless attempt to play God by means of incapsulating the world only to ignor it. This could somehow put it in the same boat with the devil. They both prefer your brain to Turing machin:-) I would leave with the eternal question "what the hell Haskell is?" and with my Santa Close emphasising Haskell's purity and my simplicity. Here: http://haskell.org/sitewiki/images/7/79/WCF.Andrzej.Jaworski.gif Have fun, -Andrzej Jaworski From andre at digirati.com.br Sun Dec 21 20:44:34 2008 From: andre at digirati.com.br (Andre Nathan) Date: Sun Dec 21 20:36:01 2008 Subject: [Haskell-cafe] Trouble with the ST monad In-Reply-To: <2f9b2d30812211647y46cfcbb5xf87ff5923f320920@mail.gmail.com> References: <1229904840.6245.5.camel@homesick> <2f9b2d30812211647y46cfcbb5xf87ff5923f320920@mail.gmail.com> Message-ID: <1229910274.6245.9.camel@homesick> On Sun, 2008-12-21 at 16:47 -0800, Ryan Ingram wrote: > The problem is that you are trying to return a mutable array out of an > ST computation. This lets the "mutability" of the computation escape. > That's what the "s" type variable is for; without it, runST is just > unsafePerformIO. Thanks! If only I knew that was the problem... It wouldn't have costed me the whole afternoon :P Is there any difference between using freeze/thaw from Data.Array.MArray versus freezeSTArray/thawSTArray from GHC.Arr? Best, Andre From wagner.andrew at gmail.com Sun Dec 21 22:14:43 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Sun Dec 21 22:07:07 2008 Subject: [Haskell-cafe] Pattern combinators In-Reply-To: <49a77b7a0812202137j23ff10edw1853f5a24eb6aae9@mail.gmail.com> References: <494DAB4A.5080509@mcmaster.ca> <49a77b7a0812202137j23ff10edw1853f5a24eb6aae9@mail.gmail.com> Message-ID: I'd love to see a copy of this go up on hackage for experimentation. Would you care to upload your code, or send it to me so I can upload it? On Sun, Dec 21, 2008 at 12:37 AM, David Menendez wrote: > On Sat, Dec 20, 2008 at 9:34 PM, Jacques Carette > wrote: > > Andrew Wagner wrote: > >> > >> Wadler posted a blog entry the other day about a paper on > pattern-matching > >> in Haskell (http://wadler.blogspot.com/). I've taken a first stab at > turning > >> it into actual code for hackage (http://hpaste.org/13215). There are > two > >> commented-out definitions that don't type-check, though, and the types > are > >> too wild for me to grok. Anybody have any suggestions for 1.) How to fix > it > >> and/or 2.) How to use data/type/newtype to simplify the types and make > it > >> more manageable? Thanks! > > > > Both errors are because you are using "any" instead of "any'"; you might > > wish to put > > import Prelude hiding any > > at the top of your code, just to avoid such confusion. > > Example 14 also uses (.->.) where it should use (.>.), and it either > needs some more parentheses or some precedence declarations for the > operators. > > > To make the types more readable (but not necessarily more manageable), I > > have made some changes to my version of this code. > > One oddity in the paper is the type of the failure continuations, () > -> ans. I'm guessing that's left over from an earlier phase of > development. In my own transcription of the library, I eliminated the > () parameter without apparent loss of functionality. > > I think I've managed to work out the structure of the types, which can > mostly be expressed in modern Haskell. > > The matching part of the patterns have this general form: > > type PMatch vec vec' ans = (vec -> ans) -> (() -> ans) -> vec' -> ans > > where vec and vec' are the list of argument types before and after the > subpattern match, and ans is the final answer. (In my code, I just use > ans instead of () -> ans for the failure continuation.) > > This gets us: > > nil :: PMatch vec vec ans > one :: a -> PMatch (a,vec) vec ans > (#) :: PMatch vec vec' ans -> PMatch vec' vec'' ans -> PMatch vec vec'' > ans > fail :: PMatch vec vec' ans > catch :: PMatch vec vec' ans -> PMatch vec vec' ans -> PMatch vec vec' ans > > These types are less general than the ones Haskell would infer, but > they do not appear to lose any functionality. > > The currying part of the pattern is less easy to analyze. I've been > able to use type families to relate the curried and uncurried form of > the function types, but I'm working with GHC 6.8, so it's possible > this won't work with the more modern implementations. > > Given the list of argument types and the answer type, generate a > curried function type: > > type family Curry vec ans > type instance Curry () ans = ans > type instance Curry (a,vec) ans = a -> Curry vec ans > > zero, succ zero, and so forth take a function in curried form and > transform it into a function that takes a nested tuple: > > type CurryDigit vec ans = Curry vec ans -> vec -> ans > > zero :: CurryDigit () ans > succ zero :: CurryDigit (a,()) ans > > succ :: CurryDigit vec ans -> CurryDigit (a,vec) ans > succ . succ :: CurryDigit vec ans -> CurryDigit (a,(b,vec)) ans > > So the currying part of the pattern will have the form: > > type PCurry vec vec' ans = CurryDigit vec' ans -> CurryDigit vec ans > > So a pattern has the type, > > type Pattern a vec vec' ans = (PCurry vec vec' ans, a -> PMatch > vec vec' ans) > > where a is the value being examined, vec and vec' are the list of > unbound argument types before and after the match, and ans is the > result. > > var :: Pattern a (a,vec) vec ans > cst :: (Eq a) => a -> Pattern a vec vec ans > pair :: Pattern a vec vec' ans -> Pattern b vec' vec'' ans -> > Pattern (a,b) vec vec'' ans > > > Coming from the other side, match takes a value and a case statement > and produces a result: > > type Case a ans = a -> (() -> ans) -> ans -- or just a -> ans -> > ans in my code > > match :: a -> Case a ans -> ans > > (|||) combines case statements: > > (|||) :: Case a ans -> Case a ans -> Case a ans > > and (->>) creates them from a pattern and a curried function, > > (->>) :: Pattern a vec () ans -> Curry vec ans -> Case a ans > > Note that (->>) requires the pattern to leave no unbound variables > after matching. > > > Given the way everything is polymorphic in ans, it may be possible to > hide it, but I haven't tried yet. > > > > The principal weakness of these pattern-matching combinators is that > there > > is no support for algebraic types, i.e. things like > > data Tree a = Leaf | Branch (Tree a) (Tree a) > > I can see how to use Typeable to deal with that, but is there a simpler > way? > > You can define the patterns manually: > > leaf = (id, \v -> case v of { Leaf -> nil; _ -> fail }) > > branch p q = (curry_p . curry_q, \v -> case v of { Branch l r -> > match_p l # match_q r; _ -> fail}) > where > (curry_p, match_p) = p > (curry_q, match_q) = q > > I assume generating these would be pretty straightforward to automate > with Template Haskell. > > -- > Dave Menendez > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081221/bd9f2468/attachment.htm From chunye.wang at nsn.com Sun Dec 21 22:15:38 2008 From: chunye.wang at nsn.com (Wang, Chunye (NSN - CN/Beijing)) Date: Sun Dec 21 22:08:06 2008 Subject: [Haskell-cafe] Can I build and install GHC 6.10.1 without previous installed ghc Message-ID: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> Hi All, I have our own Linux distribution installed in my server. it is based on RedHat 9.0. Because it is the server, I can not update it to any other linux distribution Here is my situation, I have no machine with any version of ghc installed. This is what I did % wget http://haskell.org/ghc/dist/6.10.1/ghc-6.10.1-src.tar.bz2 % wget http://haskell.org/ghc/dist/6.10.1/ghc-6.10.1-src-extralibs.tar.bz2 % tar -jxf ghc-6.10.1-src-extralibs.tar.bz2 %tar -jxvf ghc-6.10.1-src.tar.bz2 % cd ghc-6.10.1 % sh boot grep: packages: No such file or directory Booting . Booting libraries/base Booting libraries/directory /usr/share/aclocal/libgcrypt.m4:23: warning: underquoted definition of AM_PATH_LIBGCRYPT run info '(automake)Extending aclocal' or see http://sources.redhat.com/automake/automake.html#Extending-aclocal /usr/share/aclocal/ao.m4:9: warning: underquoted definition of XIPH_PATH_AO Booting libraries/editline Booting libraries/network Booting libraries/old-time Booting libraries/process Booting libraries/regex-posix Booting libraries/time Booting libraries/unix % ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Canonicalised to: x86_64-unknown-linux checking for ghc... no checking for ghc-pkg matching ... no checking for ghc-pkg... no checking whether ghc has editline package... no checking for nhc... no checking for nhc98... no checking for hbc... no checking for ld... /usr/local/bin/ld configure: error: GHC is required unless bootstrapping from .hc files. I know http://hackage.haskell.org/trac/ghc/wiki/Building/Prerequisites said that GHC 6.6 is required to build and install the GHC 6.10.1 So I try to follow the instructions http://hackage.haskell.org/trac/ghc/wiki/Building/Porting. Because I don't have any ghc installed in any machine. I have to use the "Porting GHC to a new platform " %./configure --enable-hc-boot --enable-hc-boot-unregisterised checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Canonicalised to: x86_64-unknown-linux checking for ghc... no checking for ghc-pkg matching ... no checking for ghc-pkg... no checking whether ghc has editline package... no checking for nhc... no checking for nhc98... no checking for hbc... no checking for ld... /usr/local/bin/ld checking for path to top of build tree... ./configure: line 2733: -v0: command not found ./configure: line 2737: utils/pwd/pwd: No such file or directory configure: error: cannot determine current directory I think it is because the utils/pwd/pwd.hs is not compiled and linked into the ``pwd''. So I create a bash version of pwd #!/bin/bash pwd And m make it executeble, chmod +x utils/pwd/pwd Then I try to run the ./configure --enable-hc-boot --enable-hc-boot-unregisterised again %./configure --enable-hc-boot --enable-hc-boot-unregisterised again %cd includes %make %cd .. Finnally, I found I still need ghc is intalled on the host machine. %perl --version This is perl, v5.8.5 built for x86_64-linux-thread-multi Copyright 1987-2004, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page. %gcc --version gcc (GCC) 4.1.2 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. %make --version GNU Make 3.80 Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. %autoconf --version autoconf (GNU Autoconf) 2.59 Written by David J. MacKenzie and Akim Demaille. Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. %automake --version automake (GNU automake) 1.9.2 Written by Tom Tromey . Copyright 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. %sed --version GNU sed version 4.1.2 Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, to the extent permitted by law. %diff --version diff (GNU diffutils) 2.8.1 Copyright (C) 2002 Free Software Foundation, Inc. This program comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of this program under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING. Written by Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, and Len Tower. %python -V Python 2.3.4 Best Regards Chunye Wang From dons at galois.com Sun Dec 21 22:30:49 2008 From: dons at galois.com (Don Stewart) Date: Sun Dec 21 22:23:08 2008 Subject: [Haskell-cafe] Can I build and install GHC 6.10.1 without previous installed ghc In-Reply-To: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> References: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> Message-ID: <20081222033049.GA25985@scytale.galois.com> chunye.wang: > Hi All, > > > I have our own Linux distribution installed in my server. > it is based on RedHat 9.0. Because it is the server, I can > not update it to any other linux distribution > > Here is my situation, I have no machine with any version of ghc > installed. Please use a basic linux binary. http://haskell.org/ghc/download_ghc_6_10_1.html#x86linux Such as "Linux (x86)" -- Don From chunye.wang at nsn.com Sun Dec 21 22:53:43 2008 From: chunye.wang at nsn.com (Wang, Chunye (NSN - CN/Beijing)) Date: Sun Dec 21 22:46:10 2008 Subject: [Haskell-cafe] Can I build and install GHC 6.10.1 without previous installed ghc In-Reply-To: <20081222033049.GA25985@scytale.galois.com> References: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> <20081222033049.GA25985@scytale.galois.com> Message-ID: <2667F74761A946468605DA9E63434A08692285@CNBEEXC006.nsn-intra.net> Hi Don, I tried to install the ghc 6.8.0 last year but failed for some reason. Now I decide to do it again, because I'd like to try some examples in <> Now I remember why I try to install it from source code, because the binary version has the following problem. %./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Which we'll further canonicalise into: x86_64-unknown-linux checking for path to top of build tree... pwd: timer_create: Invalid argument configure: error: cannot determine current directory I know my linux distribution is a private modified version, which is based on RedHat 9.0 I guess it is pretty old version. I also installed many other software from source code. I guess ``timer_create '' is failed because of library confliction. Best Regards Chunye Wang -----Original Message----- From: ext Don Stewart [mailto:dons@galois.com] Sent: Monday, December 22, 2008 11:31 AM To: Wang, Chunye (NSN - CN/Beijing) Cc: Haskell-Cafe@haskell.org; glasgow-haskell-users@haskell.org Subject: Re: [Haskell-cafe] Can I build and install GHC 6.10.1 without previous installed ghc chunye.wang: > Hi All, > > > I have our own Linux distribution installed in my server. > it is based on RedHat 9.0. Because it is the server, I can > not update it to any other linux distribution > > Here is my situation, I have no machine with any version of ghc > installed. Please use a basic linux binary. http://haskell.org/ghc/download_ghc_6_10_1.html#x86linux Such as "Linux (x86)" -- Don From lennart at augustsson.net Mon Dec 22 02:39:52 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Dec 22 02:32:14 2008 Subject: [Haskell-cafe] ANN: llvm-0.4.0.1 Message-ID: We have now released version 0.4.0.1 of the Haskell LLVM bindings. (This release that is quite incompatible with the old 0.0.2 release.) LLVM is a virtual machine and the bindings allow you to generate code for this virtual machine. This code can then be executed by a JIT or written to a file for further processing by the LLVM tools. The LLVM bindings has two layers. You can either use the low level bindings that is just the same as the C bindings for the LLVM. This level is quite unsafe as there is very little type checking. The recommended way is a high level binding (somewhat less complete) which eliminates many errors by leveraging the Haskell type system. A simple example, generating code for a function that adds two numbers and then calling it from Haskell: import Data.Int import LLVM.Core import LLVM.ExecutionEngine cgplus :: CodeGenModule (Function (Int32 -> Int32 -> IO Int32)) cgplus = createFunction InternalLinkage $ \ x y -> do r <- add x y ret r main = do ioplus <- simpleFunction cgplus let plus = unsafePurify ioplus print $ plus 20 22 Enjoy! Bryan O'Sullivan Lennart Augustsson From tom.davie at gmail.com Mon Dec 22 03:19:54 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Dec 22 03:12:19 2008 Subject: [Haskell-cafe] Yampa vs. Reactive In-Reply-To: <494E321E.3040905@cs.nott.ac.uk> References: <7E4F4B67-72B0-451B-9779-59FC87E24C3E@gmail.com> <49490CB1.8060405@cs.nott.ac.uk> <20003928-DA50-4240-B7F5-3BEB9E378519@gmail.com> <494A4F89.5090802@cs.nott.ac.uk> <3B30BEDA-3013-45DA-90E3-10871DC9EC67@gmail.com> <494A9136.1040903@cs.nott.ac.uk> <17684A5D-6735-45A8-BBFB-70FFE5129FD1@gmail.com> <494AF347.9010809@cs.nott.ac.uk> <4FD4AF0A-9784-48CF-A30A-F7CB998F0911@gmail.com> <494E321E.3040905@cs.nott.ac.uk> Message-ID: On 21 Dec 2008, at 13:10, Henrik Nilsson wrote: > Hi Tom, > > > In reactive, one doesn't. All behaviors and events have the same > > absolute 0 value for time. > > Right. I believe the possibility of starting behaviors later > is quite important. > > And from what Conal wrote in a related mail, I take it that this > is recognized, and that this capability is something that is > being considered for reactive? Yep, it is indeed. Thanks for this series of emails by the way. It's helped clarify in my head exactly what problems Yampa solved, and exactly which of them Reactive does or doesn't solve. Thanks Tom Davie From slehuitouze at telisma.com Mon Dec 22 04:14:22 2008 From: slehuitouze at telisma.com (Serge LE HUITOUZE) Date: Mon Dec 22 04:06:46 2008 Subject: [Haskell-cafe] Trouble with FFI on Windows2000... Message-ID: Hi Kyra (I tried to email you directly, but, for some reason, my mail bounced...), Hi Haskellers, > > dlltool -d cproj1.def -l libcproj1.a > > ghc --make testFFI_2.hs -optl-lcproj1 -optl-L. > > [...] > > This leads to an error box with message: > > "DLL (null) not found on specified path" > > dlltool -d cproj1.def -l libcproj1.a -D cproj1.dll Thanks very much for this answer, short and effective (an ideal one)! Just an additional question, just for curiosity: Does anyone know why this "-D" option doesn't appear in the following two pages? - http://www.haskell.org/haskellwiki/GHC/Using_the_FFI#Setting_up_your_build_environment_.28Visual_Studio_Specific.29 - http://www.haskell.org/haskellwiki/GHC:FAQ#GHC_on_Windows (parag. 1.4.3.4) Is this because the behavior I got is Win2K specific (hence very few people run into in 2008)? Thanks again Kyra for your precious help. --Serge From DekuDekuplex at Yahoo.com Mon Dec 22 04:35:12 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Dec 22 04:27:51 2008 Subject: [Haskell-cafe] Re: Time for a new logo? References: <20081214211504.GO27904@scytale.galois.com> <90889fe70812141327if02a189xa46997e2813363c2@mail.gmail.com> <1229290656.11108.1.camel@porges-laptop> <4e7aa0f80812141350w39e60922o20457ca813ac81b1@mail.gmail.com> Message-ID: On Sun, 14 Dec 2008 16:50:11 -0500, "sam lee" wrote: >http://i35.tinypic.com/mjon83.png >used this: http://www.simwebsol.com/ImageTool/Default.aspx This logo still has not been uploaded to the "Haskell logos/New logo ideas" (http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas) page. Could you please upload it before it is forgotten? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From duncan.coutts at worc.ox.ac.uk Mon Dec 22 04:37:32 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 22 04:30:10 2008 Subject: [Haskell-cafe] Can I build and install GHC 6.10.1 without previous installed ghc In-Reply-To: <2667F74761A946468605DA9E63434A08692285@CNBEEXC006.nsn-intra.net> References: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> <20081222033049.GA25985@scytale.galois.com> <2667F74761A946468605DA9E63434A08692285@CNBEEXC006.nsn-intra.net> Message-ID: <1229938652.5704.4.camel@localhost> On Mon, 2008-12-22 at 11:53 +0800, Wang, Chunye (NSN - CN/Beijing) wrote: > > I tried to install the ghc 6.8.0 last year but failed for some > reason. Now I decide to do it again, because I'd like to try > some examples in <> Now I remember why I try to > install it from source code, because the binary version has the > following problem. > I guess ``timer_create '' is failed because of library confliction. I suggest you use the binary for ghc-6.8.2 (not 6.8.3) or earlier because those were built on an old Red Hat 9 server and are thus compatible with older versions of glibc and the Linux kernel. If you really need ghc-6.10 (you probably do not if you're just trying examples from the Real World Haskell book) then you can build ghc-6.10.x from source once you have the ghc-6.8.2 binary installed. Duncan From duncan.coutts at worc.ox.ac.uk Mon Dec 22 04:45:34 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 22 04:38:09 2008 Subject: [Haskell-cafe] Removing/Uninstalling cabal packages ? In-Reply-To: <22f6a8f70812211130kb4c27a6g423336a195788f8a@mail.gmail.com> References: <22f6a8f70812211130kb4c27a6g423336a195788f8a@mail.gmail.com> Message-ID: <1229939134.5704.8.camel@localhost> On Sun, 2008-12-21 at 13:30 -0600, brian wrote: > On Sun, Dec 21, 2008 at 12:12 PM, Laurent Giroud wrote: > > I have been doing a few experiments with cabal packages lately and I wish to > > uninstall these to return to a cleaner package base. However, there doesn't > > seem to be a "cabal uninstall" command and reading the documentation at > > http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html does not tell > > much about how to do that manually. > > I think you want 'ghc-pkg list' and 'ghc-pkg unregister'. If you also want to remove the files then that also has to be done manually at the moment. If any volunteers would like to help us implement tracking of installed files that would be most welcome. Duncan From chunye.wang at nsn.com Mon Dec 22 04:53:53 2008 From: chunye.wang at nsn.com (Wang, Chunye (NSN - CN/Beijing)) Date: Mon Dec 22 04:46:21 2008 Subject: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc In-Reply-To: <1229938652.5704.4.camel@localhost> References: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> <20081222033049.GA25985@scytale.galois.com> <2667F74761A946468605DA9E63434A08692285@CNBEEXC006.nsn-intra.net> <1229938652.5704.4.camel@localhost> Message-ID: <2667F74761A946468605DA9E63434A086925B8@CNBEEXC006.nsn-intra.net> Hi Duncan, wget http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-x86_64-unknown-linux.tar.bz2 tar -jxvf ghc-6.8.2-x86_64-unknown-linux.tar.bz2 cd ghc-6.8.2 ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Which we'll further canonicalise into: x86_64-unknown-linux checking for path to top of build tree... pwd: timer_create: Invalid argument configure: error: cannot determine current directory Even though I can fixed this by ``cp /bin/pwd utils/pwd/pwd'' , there is still similar error ``ghc-pkg.bin: timer_create: Invalid argument'' I guess any executable file generates same error message. Best Regards Chunye Wang -----Original Message----- From: ext Duncan Coutts [mailto:duncan.coutts@worc.ox.ac.uk] Sent: Monday, December 22, 2008 5:38 PM To: Wang, Chunye (NSN - CN/Beijing) Cc: Haskell-Cafe@haskell.org Subject: RE: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc On Mon, 2008-12-22 at 11:53 +0800, Wang, Chunye (NSN - CN/Beijing) wrote: > > I tried to install the ghc 6.8.0 last year but failed for some reason. > Now I decide to do it again, because I'd like to try some examples in > <> Now I remember why I try to install it from > source code, because the binary version has the following problem. > I guess ``timer_create '' is failed because of library confliction. I suggest you use the binary for ghc-6.8.2 (not 6.8.3) or earlier because those were built on an old Red Hat 9 server and are thus compatible with older versions of glibc and the Linux kernel. If you really need ghc-6.10 (you probably do not if you're just trying examples from the Real World Haskell book) then you can build ghc-6.10.x from source once you have the ghc-6.8.2 binary installed. Duncan From bulat.ziganshin at gmail.com Mon Dec 22 04:56:22 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Dec 22 04:51:10 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> Message-ID: <995056501.20081222125622@gmail.com> Hello G?nther, Monday, December 22, 2008, 1:57:22 AM, you wrote: try -threaded, +RTS -N2, and forkOS simultaneously. it may work - i don't see reasons why other threads should be freezd why one does unsafe call nother solution is to compile library with unsafe call changed to safe. this change is always safe but make call ~10mcs slower :) > Hi Mads, > I just noticed that too. > I had been wondering why this problem does not occur with the sample app > from RWH eventhough I was employing the same technics as they did. > It just occured to me that all the DB interactions in their app are fairly > short and thus the problem never becomes apparent. > Thanks everyone, I was going crazy here, couldn't figure out what I was > doing wrong. > Would anyone happen to know of a "safe" alternative to HDBC? > G?nther > Am 21.12.2008, 23:39 Uhr, schrieb Mads Lindstr?m > : >> Hi G?nther, >> >>> Hi Mads, >>> >>> I'm using HDBC with sqlite3 >> >> Looking at >> http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Connection.hs >> and >> http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Statement.hsc >> you can see that HDBC-sqlite's foreign calls are indeed marked unsafe. >> >> /Mads >> >>> >>> G?nther >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Mon Dec 22 04:58:32 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Dec 22 04:51:22 2008 Subject: [Haskell-cafe] Trouble with the ST monad In-Reply-To: <1229910274.6245.9.camel@homesick> References: <1229904840.6245.5.camel@homesick> <2f9b2d30812211647y46cfcbb5xf87ff5923f320920@mail.gmail.com> <1229910274.6245.9.camel@homesick> Message-ID: <355138323.20081222125832@gmail.com> Hello Andre, Monday, December 22, 2008, 4:44:34 AM, you wrote: > Is there any difference between using freeze/thaw from Data.Array.MArray > versus freezeSTArray/thawSTArray from GHC.Arr? portability, at least -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ndmitchell at gmail.com Mon Dec 22 05:29:05 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Dec 22 05:21:27 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 In-Reply-To: References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com> Message-ID: <404396ef0812220229t7c2d7406m3331bf2f820cee04@mail.gmail.com> Hi Lennart, > It would be nice if HLint didn't suggest things that it will object to > in the next round. > Like > > LLVM/Core/CodeGen.hs:176:1: Eta reduce > Found: > applyArgs f g = apArgs 0 f g > Why not: > applyArgs f = apArgs 0 f The idea is to specify things one step at a time, so the user learns from the hints, as well as fixing them. However, in the case of eta reduction, doing several reductions at a time does make sense. I'll add it to the todo list. Thanks Neil From Malcolm.Wallace at cs.york.ac.uk Mon Dec 22 05:30:51 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Dec 22 05:27:26 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <20081221230712.GE25249@scytale.galois.com> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> Message-ID: <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> Don Stewart wrote: > Modify the 'unsafe' inports to be 'safe'? I don't think HDBC is going > to call back in, so should be fine. John? For those who are puzzled, Don is suggesting that foreign import ccall unsafe "foo" :: Bar -> Baz should simply be changed to foreign import ccall safe "foo" :: Bar -> Baz And in case anyone is wondering whether fiddling with safety declarations is entirely wise: "unsafe" means I, the programmer, guarantee that this foreign function cannot call back into Haskell land, so you, the compiler, are free to do unsafe things when implementing the call. "safe" means I the programmer, cannot guarantee that this foreign function is safe, so please, you the compiler, make sure that you add extra checks and assurances to ensure that the call really will be safe in case it calls back into Haskell land. The terminology seems counter-intuitive, but in other other words, a "safe" call is slower but more flexible, an "unsafe" call is fast and dangerous. Therefore it is always OK to convert an "unsafe" declaration into a "safe" one, but never OK to convert from "safe" to "unsafe" without looking at what the foreign side actually does. Regards, Malcolm From DekuDekuplex at Yahoo.com Mon Dec 22 05:55:56 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Dec 22 05:48:39 2008 Subject: [Haskell-cafe] new "Haskell logos/Logo design tools - HaskellWiki" page [Was: Re: Time for a new logo?] References: <20081214211504.GO27904@scytale.galois.com> Message-ID: In order to encourage participation in The Great 2009 Haskell Logo Contest, I have created a new "Haskell logos/Logo design tools - HaskellWiki" page (see http://haskell.org/haskellwiki/Haskell_logos/Logo_design_tools). This page is still a stub; if you have any further information on logo design tools or logo design-related resource sites, including design advice, please feel free to add to it. The more participation, the better! -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From jason.dusek at gmail.com Mon Dec 22 05:58:00 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Dec 22 05:50:22 2008 Subject: [Haskell-cafe] understanding enumerator/iteratee In-Reply-To: <2076f2f90812202135o6db3a3b0t2971d5f8ca6cb39f@mail.gmail.com> References: <42784f260812200111y320fafd4ja8d8bb1a52573808@mail.gmail.com> <2076f2f90812202135o6db3a3b0t2971d5f8ca6cb39f@mail.gmail.com> Message-ID: <42784f260812220258lb10e0dfpaee853a9989fa451@mail.gmail.com> So an iteratee is not like a cursor because it does not "own" the collection -- it just tells us how to step it. The enumerator "owns" the collection and provides a way to scope resource use? -- Jason Dusek From artyom.shalkhakov at gmail.com Mon Dec 22 06:17:33 2008 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Mon Dec 22 06:09:54 2008 Subject: [Haskell-cafe] understanding enumerator/iteratee In-Reply-To: <42784f260812220258lb10e0dfpaee853a9989fa451@mail.gmail.com> References: <42784f260812200111y320fafd4ja8d8bb1a52573808@mail.gmail.com> <2076f2f90812202135o6db3a3b0t2971d5f8ca6cb39f@mail.gmail.com> <42784f260812220258lb10e0dfpaee853a9989fa451@mail.gmail.com> Message-ID: <2076f2f90812220317q47e84d1fr37a5d0f863b8c684@mail.gmail.com> Hi Jason! 2008/12/22 Jason Dusek : > So an iteratee is not like a cursor because it does not "own" > the collection -- it just tells us how to step it. The > enumerator "owns" the collection and provides a way to scope > resource use? Iteratee does not know anything about resources, it doesn't need to. It is just a function which, given an input stream (which is either EOF, block of data or an IO error string), decides what to do, one of: * yield with some (useful) results (and with the rest of the input) * request more input by returning a continuation The enumerator on the other hand, decides when to open the resource (a file, for example), when to close it, and how to "step" through it. Iteratee only gets the fruits of this hard work. :) > it just tells us how to step it I would say that it just tells us how to react to various forms of input. :) This is much like the function you pass to foldr. I hope this clarifies iteratees a bit (and that my understanding is correct). Cheers, Artyom Shalkhakov. From duncan.coutts at worc.ox.ac.uk Mon Dec 22 06:36:47 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 22 06:29:21 2008 Subject: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc In-Reply-To: <2667F74761A946468605DA9E63434A086925B8@CNBEEXC006.nsn-intra.net> References: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> <20081222033049.GA25985@scytale.galois.com> <2667F74761A946468605DA9E63434A08692285@CNBEEXC006.nsn-intra.net> <1229938652.5704.4.camel@localhost> <2667F74761A946468605DA9E63434A086925B8@CNBEEXC006.nsn-intra.net> Message-ID: <1229945807.5704.51.camel@localhost> On Mon, 2008-12-22 at 17:53 +0800, Wang, Chunye (NSN - CN/Beijing) wrote: > Hi Duncan, > > > wget > http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-x86_64-unknown-linux.tar.bz2 > tar -jxvf ghc-6.8.2-x86_64-unknown-linux.tar.bz2 Ahh, x86-64. Those have always been built on Fedora Core 5. My only suggestion is to try older ones, eg 6.6.1. That version should still be able to built 6.10.1 from source and should still be usable for the RWH book. Duncan From duncan.coutts at worc.ox.ac.uk Mon Dec 22 06:42:22 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 22 06:34:56 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <1229946142.5704.57.camel@localhost> On Mon, 2008-12-22 at 10:30 +0000, Malcolm Wallace wrote: > For those who are puzzled, Don is suggesting that > foreign import ccall unsafe "foo" :: Bar -> Baz > should simply be changed to > foreign import ccall safe "foo" :: Bar -> Baz > > And in case anyone is wondering whether fiddling with safety > declarations is entirely wise: > > "unsafe" means I, the programmer, guarantee that this foreign function > cannot call back into Haskell land, so you, the compiler, are free to > do unsafe things when implementing the call. > > "safe" means I the programmer, cannot guarantee that this foreign > function is safe, so please, you the compiler, make sure that you add > extra checks and assurances to ensure that the call really will be > safe in case it calls back into Haskell land. > > The terminology seems counter-intuitive, but in other other words, a > "safe" call is slower but more flexible, an "unsafe" call is fast and > dangerous. Therefore it is always OK to convert an "unsafe" declaration > into a "safe" one, but never OK to convert from "safe" to "unsafe" > without looking at what the foreign side actually does. And in general we would not even bother with considering using "unsafe" for calls that are already expensive. It's only worth considering when the length of the call is always very short. For example in a database library it might make sense to use 'unsafe' on the data-access functions that extract data from a local query result but we should always use 'safe' on any DB function that might want to talk to the network (eg to get more query results). Duncan From lrpalmer at gmail.com Mon Dec 22 07:33:59 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Dec 22 07:26:21 2008 Subject: [Haskell-cafe] A hell of a question In-Reply-To: <542709579B684DFEB328B6E788464AA1@bzdryk> References: <542709579B684DFEB328B6E788464AA1@bzdryk> Message-ID: <7ca3f0160812220433y2491f5e2rffa678fed266e857@mail.gmail.com> On Sun, Dec 21, 2008 at 6:03 PM, Andrzej Jaworski wrote: > I just want to say Hello to let you know that there are some serious > entities watching you besides > monads and FBI:-) > > There has been a hell of a discussion recently about logos, languages and > religion and I want to add > to this. > > First let me disassociate Haskell from Taoism which to may taste has left > us in an unhealthy climate. > It suffices to say that Taoism is a school of clever trics and cute > aphorisms but without the > slightest attempt to explain or generalize let alone produce an abstract > idea or a system. That is > why its wisdom is non transferable in spite of majority of humans desending > from it. Haskell on the > contrary is a minority school that implements abstract ideas for problem > solving in the most > transferable way to date, so that other languages look into it for their > share. But don't worry, > thay will choke becouse it is them who practice Taoizm. Playing too many > tricks will eventually > trick them, even if some are powerful enough to brainwash dicent professors > to preach > interoperability or the like. Every viable complexity needs a single > underlying concept to survive, > including you and the universe. Microsoft and the like excluding;-) > Haskell has all that: consistency, transparency and self-contained concept. I associate Haskell with Zen, due to one of my favorite dialogues: "If it's purely functional, how do you *do* anything?" "You don't ;-)" (Courtesy of Conal Elliott) Haskell and Zen both happen to be my favorites in their respective fields (and exactly which field that is for both is somewhat fuzzy) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/c4504b53/attachment.htm From jason.dusek at gmail.com Mon Dec 22 08:18:38 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Dec 22 08:11:00 2008 Subject: [Haskell-cafe] understanding enumerator/iteratee In-Reply-To: <2076f2f90812220317q47e84d1fr37a5d0f863b8c684@mail.gmail.com> References: <42784f260812200111y320fafd4ja8d8bb1a52573808@mail.gmail.com> <2076f2f90812202135o6db3a3b0t2971d5f8ca6cb39f@mail.gmail.com> <42784f260812220258lb10e0dfpaee853a9989fa451@mail.gmail.com> <2076f2f90812220317q47e84d1fr37a5d0f863b8c684@mail.gmail.com> Message-ID: <42784f260812220518t5114a6f1nef7e178a9813fc34@mail.gmail.com> I'm taking a stab at composable streams, starting with cursors. I managed to make a derived cursor today -- as I work through this stuff, I hope to understand Iteratee/Enumerator better. -- Jason Dusek http://github.com/jsnx/streams/tree/554dd69339f027f113a6cfa16f552727ba9d92b3/Control/Stream/OneWay.hs From raeck at msn.com Mon Dec 22 08:51:15 2008 From: raeck at msn.com (Raeck Zhao) Date: Mon Dec 22 08:43:39 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list Message-ID: I am trying to define a containing function to see if a value is one of the elements within a list which is polymorphic, but failed with the following codes: > contain :: a -> [a] -> Bool > contain x [] = False > contain x (y:ys) = if x == y then True else contain x ys it seems that the problem is the 'operator' == does not support a polymorphic check? Any way can solve the problem? or any alternative solution to achieve the purpose? Thanks! Raeck _________________________________________________________________ It?s the same Hotmail?. If by ?same? you mean up to 70% faster. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/b366e3c3/attachment.htm From redcom at fedoms.com Mon Dec 22 08:52:50 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Dec 22 08:45:23 2008 Subject: [Haskell-cafe] Takusen Message-ID: Hi all, where can I find some sample code or other examples to familiarize me with Takusen? Does Takusen use safe ccall only, or does it also use ccall unsafe? G?nther From wagner.andrew at gmail.com Mon Dec 22 09:02:53 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Dec 22 08:55:16 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: References: Message-ID: The problem here is even slightly deeper than you might realize. For example, what if you have a list of functions. How do you compare two functions to each other to see if they're equal? There is no good way really to do it! So, not only is == not completely polymorphic, but it CAN'T be. There is a nice solution for this, however, and it's very simple: contain :: Eq a -> [a] -> Bool contain x [] = False contain x (y:ys) = if x == y then True else contain x ys The "Eq a" in the type signature says that 'a' must be a member of the 'Eq' typeclass. That says, in turn, that 'a' must have == defined for it. Fortunately, most types have, or can easily derive that definition. Here is the definition of the typeclass: class Eqa where(==):: a -> a -> Bool (/=):: a -> a -> Bool That is, for 'a' to be a member of 'Eq', it must have a == operator which can take 2 values of that type and return a Boolean, saying whether or not they're equal, and it must also have a definition for the /= operator, which is "not equal". These two are also defined in terms of each other, so if you define ==, you get /= for free, and vice versa. That's probably more information than you needed to know, but I hope it helps. 2008/12/22 Raeck Zhao > I am trying to define a containing function to see if a value is one of > the elements within a list which is polymorphic, but failed with the > following codes: > > contain :: a -> [a] -> Bool > > contain x [] = False > > contain x (y:ys) = if x == y then True else contain x ys it seems that > the problem is the 'operator' == does not support a polymorphic check? > Any way can solve the problem? or any alternative solution to achieve the > purpose? > Thanks! > Raeck > > ------------------------------ > It's the same Hotmail(R). If by "same" you mean up to 70% faster. Get your > account now. > > _______________________________________________ > 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/20081222/58d29b34/attachment.htm From constantine.potapov at gmail.com Mon Dec 22 09:03:13 2008 From: constantine.potapov at gmail.com (Constantine Potapov) Date: Mon Dec 22 08:55:54 2008 Subject: [Haskell-cafe] haskell for windows mobile 6 on Intel PXA270 processor Message-ID: Hi All. I'm looking for haskell interpreter/compiler for windows mobile 6 (I have an Asus A696 PDA with intel PXA270 processor). Somebody head about any haskell implementation for this platform? -- With best regards, Constantine Potapov. From jgoerzen at complete.org Mon Dec 22 09:15:46 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Dec 22 09:08:09 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <1229946142.5704.57.camel@localhost> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> <1229946142.5704.57.camel@localhost> Message-ID: <494FA112.60904@complete.org> Duncan Coutts wrote: > On Mon, 2008-12-22 at 10:30 +0000, Malcolm Wallace wrote: > >> The terminology seems counter-intuitive, but in other other words, a >> "safe" call is slower but more flexible, an "unsafe" call is fast and >> dangerous. Therefore it is always OK to convert an "unsafe" declaration >> into a "safe" one, but never OK to convert from "safe" to "unsafe" >> without looking at what the foreign side actually does. > > And in general we would not even bother with considering using "unsafe" > for calls that are already expensive. It's only worth considering when > the length of the call is always very short. > > For example in a database library it might make sense to use 'unsafe' on > the data-access functions that extract data from a local query result > but we should always use 'safe' on any DB function that might want to > talk to the network (eg to get more query results). It's difficult to anticipate the needs here. For instance, some people may be using a few very-long-running queries measured in minutes, such as the original poster. Other people, such as web app developers, may be issuing literally millions of queries, right after another, where the difference matters. I had initially used "unsafe" because of the documented performance benefit, plus I certainly am not expecting Sqlite to call back into the Haskell runtime. It seems to me strange that using "unsafe" instead of "safe" would have negative implications for threading. After all, as Malcolm said above, "it is always OK to convert an unsafe declaration into a safe one". So could the compiler be made to be smart enough to do so when it is advantageous for threading purposes? What's the best way to make this suitable for both people with many queries and those with long-running queries? I should also add that I suspect the C calls that are bothering the original poster here are the standard ones for reading results, and could be called many, many times on even a single query. -- John From dbueno at gmail.com Mon Dec 22 09:17:25 2008 From: dbueno at gmail.com (Denis Bueno) Date: Mon Dec 22 09:09:51 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: References: Message-ID: <6dbd4d000812220617s4f79aee6v31e92585d9fad9c1@mail.gmail.com> 2008/12/22 Andrew Wagner : > The problem here is even slightly deeper than you might realize. For > example, what if you have a list of functions. How do you compare two > functions to each other to see if they're equal? There is no good way really > to do it! So, not only is == not completely polymorphic, but it CAN'T be. > > There is a nice solution for this, however, and it's very simple: > > contain :: Eq a -> [a] -> Bool Please note that the syntax here should be: contain :: Eq a => a -> [a] -> Bool Denis From wagner.andrew at gmail.com Mon Dec 22 09:18:37 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Dec 22 09:10:59 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: <6dbd4d000812220617s4f79aee6v31e92585d9fad9c1@mail.gmail.com> References: <6dbd4d000812220617s4f79aee6v31e92585d9fad9c1@mail.gmail.com> Message-ID: Yes, of course, sorry for the typo. On Mon, Dec 22, 2008 at 9:17 AM, Denis Bueno wrote: > 2008/12/22 Andrew Wagner : > > The problem here is even slightly deeper than you might realize. For > > example, what if you have a list of functions. How do you compare two > > functions to each other to see if they're equal? There is no good way > really > > to do it! So, not only is == not completely polymorphic, but it CAN'T be. > > > > There is a nice solution for this, however, and it's very simple: > > > > contain :: Eq a -> [a] -> Bool > > Please note that the syntax here should be: > > contain :: Eq a => a -> [a] -> Bool > > Denis > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/bf05cd3c/attachment.htm From jefferson.r.heard at gmail.com Mon Dec 22 09:24:53 2008 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon Dec 22 09:17:14 2008 Subject: [Haskell-cafe] ANN: Control.Monad.IfElse Message-ID: <4165d3a70812220624x3a629df0he4ccdd7edebd6865@mail.gmail.com> Provides useful anaphoric and monadic versions of if-else and when, as well as infix operators for the actions to allow things like this: -- Allow the clause to be in m a whenM (Gtk.widgetIsFocus win) $ do this that -- anaphoric if. If the condition is nonempty, pass the conditional value to the "then" clause, otherwise do an action that requires no parameter. aif (lookup name list) (\file -> Right `liftM` hGetLine file) (do f <- openFile name l <- hGetLine file return $ Right (f,l)) -- infix version of Control.Monad.When (x>5) >>? putStrLn x -- infix version of anaphoric when lookup name list >>=? \value -> putStrLn value -- infix version of anaphoric whenM Gtk.widgetIntersect win rect >>=>>? \intersectingRectangle' -> Gtk.invalidate intersectingRectangle' From tom.davie at gmail.com Mon Dec 22 09:31:35 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Dec 22 09:24:14 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: References: <6dbd4d000812220617s4f79aee6v31e92585d9fad9c1@mail.gmail.com> Message-ID: On 22 Dec 2008, at 15:18, Andrew Wagner wrote: > Yes, of course, sorry for the typo. > > On Mon, Dec 22, 2008 at 9:17 AM, Denis Bueno wrote: > 2008/12/22 Andrew Wagner : > > The problem here is even slightly deeper than you might realize. For > > example, what if you have a list of functions. How do you compare > two > > functions to each other to see if they're equal? There is no good > way really > > to do it! So, not only is == not completely polymorphic, but it > CAN'T be. > > > > There is a nice solution for this, however, and it's very simple: > > > > contain :: Eq a -> [a] -> Bool > > Please note that the syntax here should be: > > contain :: Eq a => a -> [a] -> Bool > > Denis Of note, unless this is an exercise, such a function already exists -- it's called elem. How do you find such a function? You search on haskell.org/hoogle. http://haskell.org/hoogle/?hoogle=Eq+a+%3D%3E+a+-%3E+%5Ba%5D+-%3E+Bool Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/ad44253f/attachment.htm From himself at poczta.nom.pl Mon Dec 22 09:32:59 2008 From: himself at poczta.nom.pl (Andrzej Jaworski) Date: Mon Dec 22 09:25:28 2008 Subject: [Haskell-cafe] A hell of a question Message-ID: Hi Luke, When neurosurgeons split the brain into left and right hemisphere cutting it along corpus callosum the patient will talk to you with his left half and right half independently - each time unaware what his other half was talking about a moment earlier. I believe Zen emulates such split on a microscopic scale. We all go thru similar state when we conceive an original idea - if we do not write this down or formulate it immediately the discovery will loose its punch and sense of depth. The best documented and most prominent example is Hegel's discovery of dialectical logic - after extensive writing about that at some point he honestly admits loosing the original concept. But if not for his western oververbosity we might not today use the term 'naive' set theory. Every serious mathematician touching foundations is today perfectly aware of the price we pay for formulating things. But I am unaware of any virtue of trying to clap with one hand;-) Regards, -Andrzej From marlowsd at gmail.com Mon Dec 22 09:34:25 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Dec 22 09:26:53 2008 Subject: [Haskell-cafe] Re: forkIO on multicore In-Reply-To: <1229709140.10115.782.camel@localhost> References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <494BCEF6.8090707@pikewerks.com> <1229709140.10115.782.camel@localhost> Message-ID: <494FA571.70306@gmail.com> Duncan Coutts wrote: > On Fri, 2008-12-19 at 10:42 -0600, Jake McArthur wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Paul Keir wrote: >>> fibs = 0 : 1 : zipWith (+) fibs (tail fibs) >> This is a CAF (Constant Applicative Form). Since it is actually a >> constant it is never garbage collected, and is always shared, so each >> thread is only calculating it once. You have essentially created a >> lookup table. > > Though note that with all our obvious suggestions there is still no > speedup: > > heavytask m n = putMVar m $! (fibs !! 100000) > where > fibs = n : (n+1) : zipWith (+) fibs (tail fibs) > > -- so now fibs is not globally shared but is used per-heavytask > -- it is also evaluated by heavy task rather than just putting a thunk > -- into the MVar > > main = do ms <- sequence $ replicate 8 newEmptyMVar > sequence_ > [ forkIO (heavytask m n) > | (m, n) <- zip ms [0..] ] > ms' <- mapM takeMVar ms > mapM_ print ms' > > Looking at the GC stats (+RTS -t -RTS) we see that the majority of the > time in this program is spent doing GC and that when we run with -N4 the > time spent doing GC is even higher. This is an interesting example. It shows up a weakness in the GC that I'm working on fixing right now. The interesting aspect of this example is that the thread stacks get large. You can see this by using +RTS -hT: a large chunk of the heap is taken up by TSOs. Each of those (fibs !! 100000) requires linear stack, because (fibs 100000) depends on (fibs 99999), and so on. That could probably be fixed by adding some strictness, but that's not the goal here - we should still be able to run the program in parallel. So when there are large stacks around, GC takes a long time because it has to traverse stacks. But we should be able to alleviate the problem by (a) using a larger heap, and (b) using parallel GC. Not doing parallel GC is seriously going to hurt peformance, because the data will have to be moved from one CPU's cache to another. But it turns out that parallel GC is misbehaving on this example too, because it doesn't force each stack to be scanned by the same thread that is executing it - I'm working on fixing that. Having each CPU be able to GC independently would be a big improvement, of course. We think we understand how this can be done in the context of GHC, it's just a matter of doing it, but it's a big job. Parallel performance is something that we expect to make dramatic improvements over the next few months as we investigate more programs and improve the tools. The current HEAD is already a lot better than 6.10.1. Cheers, Simon From raeck at msn.com Mon Dec 22 09:35:01 2008 From: raeck at msn.com (Raeck Zhao) Date: Mon Dec 22 09:27:24 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: References: Message-ID: Thank you very much for your reply! It is really helpful! But I just found another 'problem', I just realize that the list does not support the user-defined data type? the list is also depending on the Eq function? For example, data Shape = Square | Triangle | Circle when I type either [Square, Triangle, Circle] or Square == Square there are errors! So there is no way to construct a truly polymorphic List? any way to extend the list to support some user-defined data type? Or... I define the Shape in a wrong way actually? Thanks Raeck Date: Mon, 22 Dec 2008 09:02:53 -0500 From: wagner.andrew@gmail.com To: raeck@msn.com Subject: Re: [Haskell-cafe] Defining a containing function on polymorphic list CC: haskell-cafe@haskell.org; beginners@haskell.org The problem here is even slightly deeper than you might realize. For example, what if you have a list of functions. How do you compare two functions to each other to see if they're equal? There is no good way really to do it! So, not only is == not completely polymorphic, but it CAN'T be. There is a nice solution for this, however, and it's very simple: contain :: Eq a -> [a] -> Bool contain x [] = False contain x (y:ys) = if x == y then True else contain x ys The "Eq a" in the type signature says that 'a' must be a member of the 'Eq' typeclass. That says, in turn, that 'a' must have == defined for it. Fortunately, most types have, or can easily derive that definition. Here is the definition of the typeclass: class Eq a where (==) :: a -> a -> Bool (/=) :: a -> a -> Bool That is, for 'a' to be a member of 'Eq', it must have a == operator which can take 2 values of that type and return a Boolean, saying whether or not they're equal, and it must also have a definition for the /= operator, which is "not equal". These two are also defined in terms of each other, so if you define ==, you get /= for free, and vice versa. That's probably more information than you needed to know, but I hope it helps. 2008/12/22 Raeck Zhao I am trying to define a containing function to see if a value is one of the elements within a list which is polymorphic, but failed with the following codes: > contain :: a -> [a] -> Bool > contain x [] = False > contain x (y:ys) = if x == y then True else contain x ys it seems that the problem is the 'operator' == does not support a polymorphic check? Any way can solve the problem? or any alternative solution to achieve the purpose? Thanks! Raeck It's the same Hotmail?. If by "same" you mean up to 70% faster. Get your account now. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe _________________________________________________________________ Life on your PC is safer, easier, and more enjoyable with Windows Vista?. http://clk.atdmt.com/MRT/go/127032870/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/4762dfff/attachment.htm From redcom at fedoms.com Mon Dec 22 09:40:56 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Dec 22 09:33:24 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <494FA112.60904@complete.org> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> <1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> Message-ID: Hi, I am not yet 100% certain that the unsafe calls are indeed the cause of the problem, eventhough I strongly suspect there are. I can tell you more once I have managed to rewrite all "unsafe" calls into "safe" once, reinstall HDBC.Sqlite3 and then run my app again to see the effects. My first attempt doing so was not successful, I'm not certain whether I missed an "unsafe" call or the app is using an old version of HDBC.Sqlite3 or whatever. I understand that Takusen does not use "unsafe" calls and would like to try it with that one then, but haven't find enough docs yet on how to use Takusen. G?nther Am 22.12.2008, 15:15 Uhr, schrieb John Goerzen : > Duncan Coutts wrote: >> On Mon, 2008-12-22 at 10:30 +0000, Malcolm Wallace wrote: >> >>> The terminology seems counter-intuitive, but in other other words, a >>> "safe" call is slower but more flexible, an "unsafe" call is fast and >>> dangerous. Therefore it is always OK to convert an "unsafe" >>> declaration >>> into a "safe" one, but never OK to convert from "safe" to "unsafe" >>> without looking at what the foreign side actually does. >> >> And in general we would not even bother with considering using "unsafe" >> for calls that are already expensive. It's only worth considering when >> the length of the call is always very short. >> >> For example in a database library it might make sense to use 'unsafe' on >> the data-access functions that extract data from a local query result >> but we should always use 'safe' on any DB function that might want to >> talk to the network (eg to get more query results). > > It's difficult to anticipate the needs here. For instance, some people > may be using a few very-long-running queries measured in minutes, such > as the original poster. Other people, such as web app developers, may > be issuing literally millions of queries, right after another, where the > difference matters. > > I had initially used "unsafe" because of the documented performance > benefit, plus I certainly am not expecting Sqlite to call back into the > Haskell runtime. > > It seems to me strange that using "unsafe" instead of "safe" would have > negative implications for threading. After all, as Malcolm said above, > "it is always OK to convert an unsafe declaration into a safe one". So > could the compiler be made to be smart enough to do so when it is > advantageous for threading purposes? > > What's the best way to make this suitable for both people with many > queries and those with long-running queries? > > I should also add that I suspect the C calls that are bothering the > original poster here are the standard ones for reading results, and > could be called many, many times on even a single query. > > -- John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From wagner.andrew at gmail.com Mon Dec 22 09:44:41 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Dec 22 09:37:03 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: References: Message-ID: There are two ways to fix this. Let me see if I can get my syntax right this time :) 1.) Let GHC work out the Eq instance: data Shape = Square | Triangle | Circle deriving Eq 2.) Tell GHC how to do it explicitly: data Shape = Square | Triangle | Circle instance Eq Shape where Square == Square = True Triangle == Triangle = True Circle == Circle = True _ == _ = False Note that the last line here means that any other comparisons are false. On Mon, Dec 22, 2008 at 9:35 AM, Raeck Zhao wrote: > Thank you very much for your reply! It is really helpful! > > But I just found another 'problem', I just realize that the list does not > support the user-defined data type? > the list is also depending on the Eq function? > > For example, > > data Shape = Square | Triangle | Circle > > when I type either > > [Square, Triangle, Circle] > > or > > Square == Square > > there are errors! > > So there is no way to construct a truly polymorphic List? any way to extend > the list to support some user-defined data type? > > Or... I define the Shape in a wrong way actually? > > Thanks > > Raeck > > > ------------------------------ > Date: Mon, 22 Dec 2008 09:02:53 -0500 > From: wagner.andrew@gmail.com > To: raeck@msn.com > Subject: Re: [Haskell-cafe] Defining a containing function on polymorphic > list > CC: haskell-cafe@haskell.org; beginners@haskell.org > > The problem here is even slightly deeper than you might realize. For > example, what if you have a list of functions. How do you compare two > functions to each other to see if they're equal? There is no good way really > to do it! So, not only is == not completely polymorphic, but it CAN'T be. > > There is a nice solution for this, however, and it's very simple: > > contain :: Eq a -> [a] -> Bool > contain x [] = False > contain x (y:ys) = if x == y then True else contain x ys > > The "Eq a" in the type signature says that 'a' must be a member of the 'Eq' > typeclass. That says, in turn, that 'a' must have == defined for it. > Fortunately, most types have, or can easily derive that definition. Here is > the definition of the typeclass: > > class Eqa > where (==):: a -> a -> > Bool > (/=):: a -> a -> > Bool > That is, for 'a' to be a member of 'Eq', it must have a == operator which > can take 2 values of that type and return a Boolean, saying whether or not > they're equal, and it must also have a definition for the /= operator, which > is "not equal". These two are also defined in terms of each other, so if you > define ==, you get /= for free, and vice versa. > > That's probably more information than you needed to know, but I hope it > helps. > > 2008/12/22 Raeck Zhao > > I am trying to define a containing function to see if a value is one of > the elements within a list which is polymorphic, but failed with the > following codes: > > contain :: a -> [a] -> Bool > > contain x [] = False > > contain x (y:ys) = if x == y then True else contain x ys it seems that > the problem is the 'operator' == does not support a polymorphic check? > Any way can solve the problem? or any alternative solution to achieve the > purpose? > Thanks! > Raeck > > ------------------------------ > It's the same Hotmail(R). If by "same" you mean up to 70% faster. Get your > account now. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > ------------------------------ > Life on your PC is safer, easier, and more enjoyable with Windows Vista(R). See > how > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/9c4469da/attachment.htm From bulat.ziganshin at gmail.com Mon Dec 22 09:55:02 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Dec 22 09:47:44 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <494FA112.60904@complete.org> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> <1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> Message-ID: <301934814.20081222175502@gmail.com> Hello John, Monday, December 22, 2008, 5:15:46 PM, you wrote: >> And in general we would not even bother with considering using "unsafe" >> for calls that are already expensive. It's only worth considering when >> the length of the call is always very short. the other way to look at it is to measure overhead of safe call. on 1 GHz Duron i measured 66.000 calls of trivial safe function per second, meaning 16.000 cpu ticks per call (ghc 6.8). it's rather large overhead for many trivial functions, but for calls to sql engine it seems rather small -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jgoerzen at complete.org Mon Dec 22 10:55:26 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Dec 22 10:47:51 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> <1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> Message-ID: <494FB86E.5090606@complete.org> G?nther Schmidt wrote: > Hi, > > I am not yet 100% certain that the unsafe calls are indeed the cause of > the problem, eventhough I strongly suspect there are. > > I can tell you more once I have managed to rewrite all "unsafe" calls into > "safe" once, reinstall HDBC.Sqlite3 and then run my app again to see the > effects. My first attempt doing so was not successful, I'm not certain > whether I missed an "unsafe" call or the app is using an old version of > HDBC.Sqlite3 or whatever. That is an interesting data point indeed. You might try to isolate the problem into some small section of code that reproduces it, so that we can do some more testing on our own systems. -- John > > I understand that Takusen does not use "unsafe" calls and would like to > try it with that one then, but haven't find enough docs yet on how to use > Takusen. > > G?nther > > Am 22.12.2008, 15:15 Uhr, schrieb John Goerzen : > >> Duncan Coutts wrote: >>> On Mon, 2008-12-22 at 10:30 +0000, Malcolm Wallace wrote: >>> >>>> The terminology seems counter-intuitive, but in other other words, a >>>> "safe" call is slower but more flexible, an "unsafe" call is fast and >>>> dangerous. Therefore it is always OK to convert an "unsafe" >>>> declaration >>>> into a "safe" one, but never OK to convert from "safe" to "unsafe" >>>> without looking at what the foreign side actually does. >>> And in general we would not even bother with considering using "unsafe" >>> for calls that are already expensive. It's only worth considering when >>> the length of the call is always very short. >>> >>> For example in a database library it might make sense to use 'unsafe' on >>> the data-access functions that extract data from a local query result >>> but we should always use 'safe' on any DB function that might want to >>> talk to the network (eg to get more query results). >> It's difficult to anticipate the needs here. For instance, some people >> may be using a few very-long-running queries measured in minutes, such >> as the original poster. Other people, such as web app developers, may >> be issuing literally millions of queries, right after another, where the >> difference matters. >> >> I had initially used "unsafe" because of the documented performance >> benefit, plus I certainly am not expecting Sqlite to call back into the >> Haskell runtime. >> >> It seems to me strange that using "unsafe" instead of "safe" would have >> negative implications for threading. After all, as Malcolm said above, >> "it is always OK to convert an unsafe declaration into a safe one". So >> could the compiler be made to be smart enough to do so when it is >> advantageous for threading purposes? >> >> What's the best way to make this suitable for both people with many >> queries and those with long-running queries? >> >> I should also add that I suspect the C calls that are bothering the >> original poster here are the standard ones for reading results, and >> could be called many, many times on even a single query. >> >> -- John >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From robgreayer at yahoo.com Mon Dec 22 11:01:31 2008 From: robgreayer at yahoo.com (Robert Greayer) Date: Mon Dec 22 10:53:53 2008 Subject: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc References: <2667F74761A946468605DA9E63434A08692232@CNBEEXC006.nsn-intra.net> <20081222033049.GA25985@scytale.galois.com> <2667F74761A946468605DA9E63434A08692285@CNBEEXC006.nsn-intra.net> <1229938652.5704.4.camel@localhost> <2667F74761A946468605DA9E63434A086925B8@CNBEEXC006.nsn-intra.net> Message-ID: <986682.47454.qm@web65710.mail.ac4.yahoo.com> I've recently built 6.10.1 on fairly archaic RHEL servers, both 64 and 32 bit, and the incantation that worked most seamlessly for me was to grab a really old binary release (in my case 6.2 worked) that installs without intervention, and then build up to the latest version (6.10.1) in steps -- I built 6.6 with 6.2, then 6.10.1 with 6.6, and it all worked without a problem. Of course, I'd try 6.6/binary first, but if that doesn't work, all is not lost, older binary releases may still work, and you can then bootstrap from those. Rob ----- Original Message ---- From: "Wang, Chunye (NSN - CN/Beijing)" To: Haskell-Cafe@haskell.org Sent: Monday, December 22, 2008 4:53:53 AM Subject: RE: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc Hi Duncan, wget http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-x86_64-unknown-linux.tar.bz2 tar -jxvf ghc-6.8.2-x86_64-unknown-linux.tar.bz2 cd ghc-6.8.2 ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Which we'll further canonicalise into: x86_64-unknown-linux checking for path to top of build tree... pwd: timer_create: Invalid argument configure: error: cannot determine current directory Even though I can fixed this by ``cp /bin/pwd utils/pwd/pwd'' , there is still similar error ``ghc-pkg.bin: timer_create: Invalid argument'' I guess any executable file generates same error message. Best Regards Chunye Wang -----Original Message----- From: ext Duncan Coutts [mailto:duncan.coutts@worc.ox.ac.uk] Sent: Monday, December 22, 2008 5:38 PM To: Wang, Chunye (NSN - CN/Beijing) Cc: Haskell-Cafe@haskell.org Subject: RE: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc On Mon, 2008-12-22 at 11:53 +0800, Wang, Chunye (NSN - CN/Beijing) wrote: > > I tried to install the ghc 6.8.0 last year but failed for some reason. > Now I decide to do it again, because I'd like to try some examples in > <> Now I remember why I try to install it from > source code, because the binary version has the following problem. > I guess ``timer_create '' is failed because of library confliction. I suggest you use the binary for ghc-6.8.2 (not 6.8.3) or earlier because those were built on an old Red Hat 9 server and are thus compatible with older versions of glibc and the Linux kernel. If you really need ghc-6.10 (you probably do not if you're just trying examples from the Real World Haskell book) then you can build ghc-6.10.x from source once you have the ghc-6.8.2 binary installed. Duncan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From redcom at fedoms.com Mon Dec 22 11:17:56 2008 From: redcom at fedoms.com (=?UTF-8?B?R8KfdWVudGhlciBTY2htaWR0?=) Date: Mon Dec 22 11:10:23 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <494FB86E.5090606@complete.org> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> <1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> <494FB86E.5090606@complete.org> Message-ID: <494FBDB4.2010708@fedoms.com> John Goerzen schrieb: > G?nther Schmidt wrote: > >> Hi, >> >> I am not yet 100% certain that the unsafe calls are indeed the cause of >> the problem, eventhough I strongly suspect there are. >> >> I can tell you more once I have managed to rewrite all "unsafe" calls into >> "safe" once, reinstall HDBC.Sqlite3 and then run my app again to see the >> effects. My first attempt doing so was not successful, I'm not certain >> whether I missed an "unsafe" call or the app is using an old version of >> HDBC.Sqlite3 or whatever. >> > > That is an interesting data point indeed. You might try to isolate the > problem into some small section of code that reproduces it, so that we > can do some more testing on our own systems. > > -- John > > I'd love to provide you with it but you'd have to manage a query that takes a long time to finish yourself. From Alistair.Bayley at invesco.com Mon Dec 22 11:28:03 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Mon Dec 22 11:20:25 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <1229897782.4495.7.camel@localhost.localdomain><1229899191.4495.13.camel@localhost.localdomain><20081221230712.GE25249@scytale.galois.com><20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk><1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt > > I understand that Takusen does not use "unsafe" calls and > would like to > try it with that one then, but haven't find enough docs yet > on how to use > Takusen. Not a lot of detailed examples exist for Takusen. I'm hoping the documentation for Database.Enumerator is a reasonable place to start. http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html I just reviewed the Takusen code and, for no apparent reason, the ODBC module specifies unsafe for all of its FFI imports, but the other modules do not (so they get the default, which I assume is safe). I also was not aware of unsafe calls blocking other threads. I'll change the ODBC imports to be safe (or rather, unspecified). Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From bulat.ziganshin at gmail.com Mon Dec 22 11:48:57 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Dec 22 11:41:43 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> References: <1229897782.4495.7.camel@localhost.localdomain><1229899191.4495.13.camel@localhost.localdomain><20081221230712.GE25249@scytale.galois.com><20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk><1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> Message-ID: <1718074218.20081222194857@gmail.com> Hello Alistair, Monday, December 22, 2008, 7:28:03 PM, you wrote: > safe). I also was not aware of unsafe calls blocking other threads. they don't to it directly. but without -threaded +RTS -N (or forkOS) there is only 1 OS thread that runs all haskell threads. unsafe call blocks it untill call finished, while safe call allows to reuse it for other haskell threads execution. i've attached old ghc commentary on this topic, although things may be significantly changed ATM -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: The GHC Commentary - Supporting multi-threaded interoperation.htm Type: application/octet-stream Size: 16646 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/e26b53f0/TheGHCCommentary-Supportingmulti-threadedinteroperation.obj From peter.padawitz at udo.edu Mon Dec 22 12:19:07 2008 From: peter.padawitz at udo.edu (Peter Padawitz) Date: Mon Dec 22 12:11:29 2008 Subject: [Haskell-cafe] monad constraint + record update Message-ID: <494FCC0B.30308@udo.edu> I'd like to define a monad Set for types in the class Eq. But how can the arguments of Set be constrained when Set is defined as an instance of Monad? instance Eq a => Monad Set where ... obviously cannot work. Is there a standard update function for fields in data types, something that OO programmers do with assignments like obj.attr := value ? Peter From eelco at lempsink.nl Mon Dec 22 12:39:33 2008 From: eelco at lempsink.nl (Eelco Lempsink) Date: Mon Dec 22 12:31:58 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <3d96ac180812211326s46953569wdce3c65f76abeb42@mail.gmail.com> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> <20081221212333.GB25249@scytale.galois.com> <3d96ac180812211326s46953569wdce3c65f76abeb42@mail.gmail.com> Message-ID: <44D34BB4-5732-4E29-8684-5091FD502810@lempsink.nl> On 21 dec 2008, at 22:26, Sebastian Sylvan wrote: > I am very shortly travelling abroad for several weeks and will not > have (reliable access to) a computer, but isn't this a task for one > of the haskell web-apps people (HSP, HAppS, Turbinado, etc.) to show > us once and for all why *their* library is better than the > competition? :-) Hmm, right. I started on a thing in HAppS. See http://github.com/eelco/voting/ for the source code (contributors more than welcome!) and http://code.tupil.com/voting/ for a live demo. It relies heavily on javascript, needs some work on the UI and there are a lot of features that could be added, but "it works". -- Regards, Eelco Lempsink -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/949ccbfc/PGP.bin From loup.vaillant at gmail.com Mon Dec 22 13:14:41 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Mon Dec 22 13:07:04 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <44D34BB4-5732-4E29-8684-5091FD502810@lempsink.nl> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> <20081221212333.GB25249@scytale.galois.com> <3d96ac180812211326s46953569wdce3c65f76abeb42@mail.gmail.com> <44D34BB4-5732-4E29-8684-5091FD502810@lempsink.nl> Message-ID: <6f9f8f4a0812221014x26fbe18ev72a183df8481b9dc@mail.gmail.com> 2008/12/22 Eelco Lempsink : > Hmm, right. I started on a thing in HAppS. See > http://github.com/eelco/voting/ for the source code (contributors more than > welcome!) and http://code.tupil.com/voting/ for a live demo. It relies > heavily on javascript, needs some work on the UI and there are a lot of > features that could be added, but "it works". Great. Could it be further hacked to accept ties, as suggested by Sebastian? Something like: thingie1 thingie1bis thingie3 thingie4 thingie4bis Regards, Loup From redcom at fedoms.com Mon Dec 22 13:23:18 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Dec 22 13:15:45 2008 Subject: [Haskell-cafe] Problems Installing Takusen with Sqlite Backend In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> <1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> Message-ID: Hi Alistair, what does it take to install Takusen on Win32 with Sqlite backend? I did manage to install *plain* Takusen via cabal install by downgrading to Cabal-1.4 but when I want to cabal-install takusen -fsqlite it complains about a missing sqlite3. What do I need to fix? G?nther From duncan.coutts at worc.ox.ac.uk Mon Dec 22 13:28:03 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 22 13:20:36 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <494FA112.60904@complete.org> References: <1229897782.4495.7.camel@localhost.localdomain> <1229899191.4495.13.camel@localhost.localdomain> <20081221230712.GE25249@scytale.galois.com> <20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk> <1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org> Message-ID: <1229970483.5704.66.camel@localhost> On Mon, 2008-12-22 at 08:15 -0600, John Goerzen wrote: > Duncan Coutts wrote: > > On Mon, 2008-12-22 at 10:30 +0000, Malcolm Wallace wrote: > > > >> The terminology seems counter-intuitive, but in other other words, a > >> "safe" call is slower but more flexible, an "unsafe" call is fast and > >> dangerous. Therefore it is always OK to convert an "unsafe" declaration > >> into a "safe" one, but never OK to convert from "safe" to "unsafe" > >> without looking at what the foreign side actually does. > > > > And in general we would not even bother with considering using "unsafe" > > for calls that are already expensive. It's only worth considering when > > the length of the call is always very short. > > > > For example in a database library it might make sense to use 'unsafe' on > > the data-access functions that extract data from a local query result > > but we should always use 'safe' on any DB function that might want to > > talk to the network (eg to get more query results). > > It's difficult to anticipate the needs here. For instance, some people > may be using a few very-long-running queries measured in minutes, such > as the original poster. Other people, such as web app developers, may > be issuing literally millions of queries, right after another, where the > difference matters. The cost of a safe call is not really that high. In comparison to something a C function that just extracts a member from a structure it's high, but compared to executing even a simple SQL query I expect it's not even measurable. > I had initially used "unsafe" because of the documented performance > benefit, plus I certainly am not expecting Sqlite to call back into the > Haskell runtime. > > It seems to me strange that using "unsafe" instead of "safe" would have > negative implications for threading. After all, as Malcolm said above, > "it is always OK to convert an unsafe declaration into a safe one". So > could the compiler be made to be smart enough to do so when it is > advantageous for threading purposes? I think it could only do it by turning all "unsafe" functions into "safe" ones. As I understand it, the ability to switch rts capability is the more expensive of the properties that "safe" provides (compared to allowing the function to be re-entrant) because it involves pthread mutexes. > What's the best way to make this suitable for both people with many > queries and those with long-running queries? If the squlite API distinguishes executing a query (potentially long running) from extracting data from the result set (always quick) then it would be possible to mark the former safe and the latter unsafe and still not impose any great overhead on any user. Duncan From claus.reinke at talk21.com Mon Dec 22 13:49:16 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Dec 22 13:41:41 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0 References: <404396ef0812200155of1d4331tc35ca0a34609c8@mail.gmail.com><404396ef0812200734w5aae1463t11531d6bac6fc0a4@mail.gmail.com> Message-ID: <5A315A793BA94075B6F2939FC2BFFF89@cr3lt> > Well, sort of. Ok, we can parse that. Let's assume a variable x holds > the output of :show modules as a String. We call lines on it, then map > words on it, do a !! 2 on it, and we get ["Util.hs,", "Recorder.hs,", > "Game.hs,", "Monadius.hs,", "Demo.hs,"]. Chuck in a map (filter (\= > ',')), and we get a good list. We can turn the list into a string > suitable for hlint with a quick unwords. > > So our long sought after command becomes ':def hoogle (\_ -> return $ > ":! " ++ (unwords $ map (filter (\= ',')) $ (map words $ lines x) !! > 2))'. But wait, how do we get 'x'? How do we call :show modules inside > a Haskell expression? I have carefully looked over > http://haskell.org/haskellwiki/GHC/GHCi#Using_GHCi and > http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-commands.html > and my conclusion is that you can't. You can't do a let x = :show > modules, there is no function which will take ":show modules", and so > on. :functions can accept Haskell output, but it's a one-way barrier. > It's no good writing Haskell functions which need information from the > :functions. The first url includes a link to a .ghci mini-tutorial (section 4) that, among other things, implements :redir -- execute , redirecting stdout to Happy Holidays!-) Claus From miguelimo38 at yandex.ru Mon Dec 22 13:55:27 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Dec 22 13:47:54 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: References: Message-ID: <09A55400-D43E-4B6C-9038-20C6A32AEDB0@yandex.ru> On 22 Dec 2008, at 17:35, Raeck Zhao wrote: > But I just found another 'problem', I just realize that the list > does not support the user-defined data type? Don't worry, it does. > the list is also depending on the Eq function? No, it doesn't. > data Shape = Square | Triangle | Circle > > [Square, Triangle, Circle] Should work fine. > or > > Square == Square Wouldn't work unless you declare your type "Shape" an instance of class "Eq" - which can be done automatically. From lrpalmer at gmail.com Mon Dec 22 14:01:09 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Dec 22 13:53:30 2008 Subject: [Haskell-cafe] Defining a containing function on polymorphic list In-Reply-To: References: Message-ID: <7ca3f0160812221101yaa51da9s9d158f08cbb2150a@mail.gmail.com> 2008/12/22 Raeck Zhao > Thank you very much for your reply! It is really helpful! > > But I just found another 'problem', I just realize that the list does not > support the user-defined data type? > the list is also depending on the Eq function? > > For example, > > data Shape = Square | Triangle | Circle > > when I type either > > [Square, Triangle, Circle] > This is perfectly legal, but GHCi won't be able to print it, because there is no Show instance for Shape. You can declare one: instance Show Shape where show Square = "Square" show Triagle = "Triangle" show Circle = "Circle" This can be generated automatically when you declare the type, by using: data Shape = Square | Triangle | Circle deriving (Show) > > > or > > Square == Square > Similarly, to use (==), you need an Eq instance, which can be defined much in the same way as the Show instance above (deriving also works on Eq -- don't generalize too hastily; not all classes work with deriving). Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/d91c3e78/attachment.htm From miguelimo38 at yandex.ru Mon Dec 22 14:16:01 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Dec 22 14:08:29 2008 Subject: [Haskell-cafe] monad constraint + record update In-Reply-To: <494FCC0B.30308@udo.edu> References: <494FCC0B.30308@udo.edu> Message-ID: <87C19400-59DC-49C6-A583-0B5C6816A6DF@yandex.ru> You can use a continuation trick I describe below. First of all, I would like to work in a more general situation. So, instead of working with Set, I'd like to declare two classes: > class Returnable m a where ret :: a -> m a and > class Bindable m a b where bind :: m a -> (a -> m b) -> m b I'm sure you're able to define instances like "instance Ord a => Returnable Set a" by yourself. You'll need MultiParamTypeClasses and FlexibleInstances for that to work. Now, the trick: > newtype Restricted r m a = Restricted ((a -> m r) -> m r) > instance Monad (Restricted r m) where > return x = Restricted $ \h -> h x > Restricted g >>= f = Restricted $ \h -> g $ \x -> let Restricted g' = f x in g' h Quite simple, and doesn't mention pseudo-monadic structure of "m" at all. Now, the fun part: > embed :: Bindable m a r => m a -> Restricted r m a > embed mx = Restricted (bind mx) > unembed :: Returnable m r => Restricted r m r -> m r > unembed (Restricted g) = g ret You may also want another class > class Summable m a where > zero :: m a > plus :: m a -> m a -> m a and now you can have > instance Summable m r => MonadPlus (Restricted r m) where > mzero = Restricted $ const zero > Restricted g1 `mplus` Restricted g2 = Restricted $ \h -> g1 h `plus` g2 h From now on, you can do something like that: > unembed $ do x <- embed $ Set.fromList [6,2,3] > (do y <- return x > z <- embed $ Set.fromList [1..2] > guard $ y < 5 > return $ y + z) > `mplus` return 10 and have "fromList [3,4,5,10]", as expected On 22 Dec 2008, at 20:19, Peter Padawitz wrote: > I'd like to define a monad Set for types in the class Eq. But how > can the arguments of Set be constrained when Set is defined as an > instance of Monad? instance Eq a => Monad Set where ... obviously > cannot work. > > Is there a standard update function for fields in data types, > something that OO programmers do with assignments like obj.attr := > value ? > > Peter > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From himself at poczta.nom.pl Mon Dec 22 14:17:59 2008 From: himself at poczta.nom.pl (Andrzej Jaworski) Date: Mon Dec 22 14:10:35 2008 Subject: [Haskell-cafe] A hell of a question References: <542709579B684DFEB328B6E788464AA1@bzdryk> Message-ID: Arnaud Bailly kindly exposed my mistake: I cited Leibniz Monadology attributing it to Spinoza. Call me idiot but it wasn't thoughtless mistake, I really mixed up Spinoza's concept of 'modes' with Leibniz's concept of 'monad'. But it is because of my laziness rather than foolishness (at least this time). My argument is that in his final writings Leibniz's 'monads' encompass reality as perceptions and emanate from God as thought emanates from the mind, which is exactly what Spinoza's 'modes' are about. So monads and modes being equal I prefer Spinoza as a patron for Haskell for his purity of cause-effect treatment. Arnold adds another Haskell-Spinoza nicety, I hope he won't mind my including his all letter. Thank you Arnold, it is encouraging to find guys like you. Philosophy is not my thing but I believe every man should tackle it as exercise. Hello Andrzej, Thanks a lot for your bit of rationalism among all these devotions :-) I think however that you are confusing Spinoza with Leibniz in the following assertion. Monads are a concept invented by the latter, together with the famous "the best possible world ever" mocked by Voltaire in "Candide". The comparison between Haskell and spinozism is rather interesting though, especially when one considers that Spinoza's "Ethic" is based on the idea that the ultimate goal of one self is to increase its power to live, an affect which it calls "Joy". Thinking of Haskell as a way to increase one's joy and one's power is a nice thought. Regards, Arnaud Bailly From wqeqweuqy at hotmail.com Mon Dec 22 15:07:32 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Mon Dec 22 15:00:06 2008 Subject: [Haskell-cafe] concurrent haskell: thread priorities Message-ID: From what i understand (correct me if I'm wrong): The threaded RT creates an OS thread for each CPU/core on the system and uses them to multiplex userland threads. These are context switched whenever they block/yield/gc and no priorities can be assigned. It seems like we could get some priority based scheduling (and still be slackers) if we allow marked green threads to be strictly associated with a specific OS thread (forkChildIO?). Its not a very good solution, but it seems easy to implement and would be nice for the few problems that really need priority based scheduling. How many of those problems involve having 1 thread running at high/realtime priority? Maybe most? From westondan at imageworks.com Mon Dec 22 15:08:21 2008 From: westondan at imageworks.com (Dan Weston) Date: Mon Dec 22 15:00:46 2008 Subject: [Haskell-cafe] "Rewrite thunk action" rule? In-Reply-To: <20081221172716.GC26638@petertodd.org> References: <20081221080201.GB26638@petertodd.org> <7ca3f0160812210156m2b2a194br7f0870644a799287@mail.gmail.com> <20081221172716.GC26638@petertodd.org> Message-ID: <494FF3B5.7000308@imageworks.com> Peter Todd wrote: > Not quite. If I have a thunk, at the low level somewhere it must refer > to the transform function, the transform matrix, and the element that is > to be transformed. If I apply another transform to that unevaluated > thunk, my understanding is that haskell will represent it as such: > > thunk transform Ta (thunk transform Tb e) > > When I want the following: > > thunk transform (Ta * Tb) e Is this an example of a Thunktor? From cristiano.paris at gmail.com Mon Dec 22 15:08:29 2008 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Mon Dec 22 15:01:06 2008 Subject: [Haskell-cafe] monad constraint + record update In-Reply-To: <494FCC0B.30308@udo.edu> References: <494FCC0B.30308@udo.edu> Message-ID: On Mon, Dec 22, 2008 at 6:19 PM, Peter Padawitz wrote: > I'd like to define a monad Set for types in the class Eq. But how can the > arguments of Set be constrained when Set is defined as an instance of Monad? > instance Eq a => Monad Set where ... obviously cannot work. Shouldn't you impose the constraint when defining functions operating on Set values? I guess that the contraint should be enforced not only when dealing with monadic code, but also whenever it appears in your program. > Is there a standard update function for fields in data types, something that > OO programmers do with assignments like obj.attr := value ? Your statement doesn't make much sense in the functional world of Haskell. There's a record update construct which may resemble the OO data update operation but it makes a whole new copy of the original value, i.e.: foo a = a { attr = value } which is basically like doing: foo a = a + 2 Cristiano From bulat.ziganshin at gmail.com Mon Dec 22 15:14:46 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Dec 22 15:07:33 2008 Subject: [Haskell-cafe] concurrent haskell: thread priorities In-Reply-To: References: Message-ID: <11545907.20081222231446@gmail.com> Hello Neal, Monday, December 22, 2008, 11:07:32 PM, you wrote: > The threaded RT creates an OS thread for each CPU/core on the system and > uses them to multiplex userland threads. These are context switched > whenever they block/yield/gc and no priorities can be assigned. not exactly. amount of OS threads created controlled by +RTS -N option to the program; unless program has special function that RTS calls to set up this value they are switched on every minor GC which by default occurs after each 256kb allocated which is rather frequent event > It seems like we could get some priority based scheduling (and still be > slackers) if we allow marked green threads to be strictly associated > with a specific OS thread (forkChildIO?). forkOS creates new haskell thread and new OS thread specially for it -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From brianchina60221 at gmail.com Mon Dec 22 15:55:23 2008 From: brianchina60221 at gmail.com (brian) Date: Mon Dec 22 15:47:44 2008 Subject: [Haskell-cafe] OpenAL Message-ID: <22f6a8f70812221255r1d45f279w5f7714cf86f243fc@mail.gmail.com> Does the example code at http://articles.bluishcoder.co.nz/Haskell/OpenAL work for anyone? I added some putStrLns to see the device and context, and get $ ./Main2 Device (ALCdevice 0x08a744c8) Context (ALCcontext 0x08aabda0) AL lib: alSource.c:2291: alcDestroyContext(): 1 Source(s) NOT deleted AL lib: alBuffer.c:1097: exit() 2 Buffer(s) NOT deleted and no sound. I had more complex code using OpenAL working some time ago, but the sound was crackly because my distribution used the original OpenAL implementation. Now that people are switching to OpenAL Soft, Haskell's OpenAL seems to be acting strangely. I mailed Sven in September, but didn't hear back. From jgoerzen at complete.org Mon Dec 22 15:59:16 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Dec 22 15:51:39 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> Message-ID: <20081222205916.GA17953@hustlerturf.com> On Mon, Dec 22, 2008 at 04:28:03PM -0000, Bayley, Alistair wrote: > > From: haskell-cafe-bounces@haskell.org > > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt > > > > I understand that Takusen does not use "unsafe" calls and > > would like to > > try it with that one then, but haven't find enough docs yet > > on how to use > > Takusen. > > Not a lot of detailed examples exist for Takusen. I'm hoping the documentation for Database.Enumerator is a reasonable place to start. > http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html > > I just reviewed the Takusen code and, for no apparent reason, the ODBC module specifies unsafe for all of its FFI imports, but the other modules do not (so they get the default, which I assume is safe). I also was not aware of unsafe calls blocking other threads. I'll change the ODBC imports to be safe (or rather, unspecified). Makes sense. I will make the similar change in all HDBC backends. -- John From redcom at fedoms.com Mon Dec 22 16:12:32 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Dec 22 16:05:10 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <20081222205916.GA17953@hustlerturf.com> References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> Message-ID: Hi guys, I just tried to forkIO-off the database code to keep the UI responsive using Takusen with Sqlite this time. The problem persists though, the UI freezes. AFAIK the sqlite-Takusen code does not use unsafe ccall which would block the thread, so that might not be the cause of the problem after all. Before you guys make the effort to "fix" this you might see if you can reproduce the problem maybe uploading a 50 MB file into an Sqlite database, for instance, or something else that will keep the database busy for some time in a row. I did not use -threaded and forkOS though. G?nther Am 22.12.2008, 21:59 Uhr, schrieb John Goerzen : > On Mon, Dec 22, 2008 at 04:28:03PM -0000, Bayley, Alistair wrote: >> > From: haskell-cafe-bounces@haskell.org >> > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt >> > >> > I understand that Takusen does not use "unsafe" calls and >> > would like to >> > try it with that one then, but haven't find enough docs yet >> > on how to use >> > Takusen. >> >> Not a lot of detailed examples exist for Takusen. I'm hoping the >> documentation for Database.Enumerator is a reasonable place to start. >> http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html >> >> I just reviewed the Takusen code and, for no apparent reason, the ODBC >> module specifies unsafe for all of its FFI imports, but the other >> modules do not (so they get the default, which I assume is safe). I >> also was not aware of unsafe calls blocking other threads. I'll change >> the ODBC imports to be safe (or rather, unspecified). > > Makes sense. I will make the similar change in all HDBC backends. > > -- John > From dave at zednenem.com Mon Dec 22 16:20:14 2008 From: dave at zednenem.com (David Menendez) Date: Mon Dec 22 16:12:35 2008 Subject: [Haskell-cafe] Pattern combinators In-Reply-To: References: <494DAB4A.5080509@mcmaster.ca> <49a77b7a0812202137j23ff10edw1853f5a24eb6aae9@mail.gmail.com> Message-ID: <49a77b7a0812221320r28b35e3ak179e7275c34e3bd1@mail.gmail.com> On Sun, Dec 21, 2008 at 10:14 PM, Andrew Wagner wrote: > I'd love to see a copy of this go up on hackage for experimentation. Would > you care to upload your code, or send it to me so I can upload it? I've uploaded my latest version to . It explicitly makes patterns polymorphic over the answer type of the case statement by making Pattern a newtype and universally quantifying the (un)currying and matching functions. For example, (->>) :: Pattern a () vec -> Curry vec ans -> Case a ans I'm not sure it makes sense to create a package just yet. At the very least, you should ask Morten Rhiger first. The type signatures are mine, but the code is mostly straight transcriptions from his paper. -- Dave Menendez From duncan.coutts at worc.ox.ac.uk Mon Dec 22 16:36:35 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 22 16:29:08 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> Message-ID: <1229981795.5704.76.camel@localhost> On Mon, 2008-12-22 at 22:12 +0100, G?nther Schmidt wrote: > Hi guys, > > I just tried to forkIO-off the database code to keep the UI responsive > using Takusen with Sqlite this time. > > The problem persists though, the UI freezes. You might need to provide us more details on the GUI code. As I understand if you're using gtk2hs. You need to make sure that you're not blocking the GUI event loop by making blocking calls in event handlers. All blocking stuff has to be run via forkIO and the event handler must be allowed to return so that Gtk+ can redraw windows etc. In this context, by "blocking" I mean blocking a single Haskell thread, which is of course different from the safe/unsafe foreign calls which blocks a whole OS thread and thus all the Haskell threads. Duncan From redcom at fedoms.com Mon Dec 22 16:55:03 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Dec 22 16:47:39 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <1229981795.5704.76.camel@localhost> References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> <1229981795.5704.76.camel@localhost> Message-ID: Hi, I put in on hpaste: http://hpaste.org/13264 slightly simplified G?nther Am 22.12.2008, 22:36 Uhr, schrieb Duncan Coutts : > On Mon, 2008-12-22 at 22:12 +0100, G?nther Schmidt wrote: >> Hi guys, >> >> I just tried to forkIO-off the database code to keep the UI responsive >> using Takusen with Sqlite this time. >> >> The problem persists though, the UI freezes. > > You might need to provide us more details on the GUI code. As I > understand if you're using gtk2hs. You need to make sure that you're not > blocking the GUI event loop by making blocking calls in event handlers. > All blocking stuff has to be run via forkIO and the event handler must > be allowed to return so that Gtk+ can redraw windows etc. > > In this context, by "blocking" I mean blocking a single Haskell thread, > which is of course different from the safe/unsafe foreign calls which > blocks a whole OS thread and thus all the Haskell threads. > > Duncan > From bhurt at spnz.org Mon Dec 22 17:31:28 2008 From: bhurt at spnz.org (Brian Hurt) Date: Mon Dec 22 17:23:56 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? Message-ID: I wrote my own implementation of MaybeT (which was a usefull exercise), but a quick google showed: http://www.haskell.org/haskellwiki/New_monads/MaybeT But I'm wondering why it's not in the standard library. The standards committee just hasn't gotten around to it yet? Or was there some discussion of this in the past on some (public) maillist, that my admittedly shallow googling failed to uncover, that someone could point me at? Thanks. Brian From thomas.dubuisson at gmail.com Mon Dec 22 17:42:55 2008 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Mon Dec 22 17:35:17 2008 Subject: [Haskell-cafe] concurrent haskell: thread priorities In-Reply-To: References: Message-ID: <4c44d90b0812221442p2933e84dl90c81bb2f986dd3c@mail.gmail.com> > > It seems like we could get some priority based scheduling (and still be > slackers) if we allow marked green threads to be strictly associated with a > specific OS thread (forkChildIO?). I think you want the GHC-only GHC.Conc.forkOnIO Suggestions like this are more motivation for the suggestion [1] to adopt a re-engineered / haskell-based RTS [2]. Tom [1] http://www.reddit.com/r/haskell_proposals/comments/7itaz/simple_robust_maintainable_rts_for_ghc_io_pdf/ [2] http://www.seas.upenn.edu/~lipeng/homepage/papers/lmpjt07hw.pdf -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/4eb8bbc7/attachment.htm From isaacdupree at charter.net Mon Dec 22 17:51:58 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Mon Dec 22 17:44:31 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <494EA1EE.1010606@cogito.org.uk> References: <494EA1EE.1010606@cogito.org.uk> Message-ID: <49501A0E.8000408@charter.net> (responding with just a bit of possibly relevant context, not always directly) Paul Johnson wrote: > I've lived through a couple of corporate rebranding exercises in my time, and > I've read about some others. They follow a pattern: > ... > 2. The new branding is released with as much fanfare as possible. Press > releases are released. Staff are given briefings about the significance > of the whole exercise and the bold new future that it symbolises. I don't think our choice of logo is quite as significant as a corporate logo. We could even use more than one logo if we wanted (maybe different people or different places). The current logo is prominent on the haskell.org (and wikipedia), mainly... places I rarely see, when working on Haskell. I see a couple things people are trying to do -> Self-descriptive, without trying to change the way we are as a community or a language -> Inviting to newcomers, mostly independent of how we actually work (although better if we advertize things we can actually provide, of course) I don't think it's trying to create a change in the language or the community, mostly it's to reflect the change that has already happened. > 3. The staff universally agree that the new logo is not a patch on the old > one. The old one was a much loved friend; it stood for something; people > have spent years working for it. The new one is obviously a piece of > cheap gimcrackery yup, I'll miss the old logo. To me, it still looks beautiful, clean and fitting. > A paradox of the Haskell world is that, while the language is Vulcan, the > community around it is dominated by Warm Fuzziness. Clearly the two are not > mutually exclusive. nice observation! > A rebranding exercise needs to start with a short list of adjectives that the > brand is to represent, good idea... although we could just be attracted by whatever proposed logo happens to have beauty instead, if our only purpose is not to be stuck with an ugly logo. > and I think that the Haskell community needs to decide > this before it fires up Inkscape. or in parallel with :-) -- random creativity can help us start thinking about what we don't want to see, and why we don't want to see it, too -Isaac From s.clover at gmail.com Mon Dec 22 18:00:48 2008 From: s.clover at gmail.com (Sterling Clover) Date: Mon Dec 22 17:53:08 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <20081222205916.GA17953@hustlerturf.com> References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> Message-ID: Thanks John! I've been running into this quite a bit with the ODBC backend as well. Having an entire server app freeze because MS SQL Server decides to deadlock is rather unpleasant. Cheers, Sterl. On Mon, Dec 22, 2008 at 3:59 PM, John Goerzen wrote: > On Mon, Dec 22, 2008 at 04:28:03PM -0000, Bayley, Alistair wrote: > > > From: haskell-cafe-bounces@haskell.org > > > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt > > > > > > I understand that Takusen does not use "unsafe" calls and > > > would like to > > > try it with that one then, but haven't find enough docs yet > > > on how to use > > > Takusen. > > > > Not a lot of detailed examples exist for Takusen. I'm hoping the > documentation for Database.Enumerator is a reasonable place to start. > > http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html > > > > I just reviewed the Takusen code and, for no apparent reason, the ODBC > module specifies unsafe for all of its FFI imports, but the other modules do > not (so they get the default, which I assume is safe). I also was not aware > of unsafe calls blocking other threads. I'll change the ODBC imports to be > safe (or rather, unspecified). > > Makes sense. I will make the similar change in all HDBC backends. > > -- John > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/d3410734/attachment.htm From lrpalmer at gmail.com Mon Dec 22 18:29:32 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Dec 22 18:21:53 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? In-Reply-To: References: Message-ID: <7ca3f0160812221529x52d9e55bt8b33a782574282b6@mail.gmail.com> On Mon, Dec 22, 2008 at 3:31 PM, Brian Hurt wrote: > > I wrote my own implementation of MaybeT (which was a usefull exercise), but > a quick google showed: > > http://www.haskell.org/haskellwiki/New_monads/MaybeT > > But I'm wondering why it's not in the standard library. The standards > committee just hasn't gotten around to it yet? Or was there some discussion > of this in the past on some (public) maillist, that my admittedly shallow > googling failed to uncover, that someone could point me at? Yeah, it'd be useful. Doesn't really matter, though, because it's on Hackage (http://hackage.haskell.org), so it's just a cabal install MaybeT away. Now that cabal and cabal-install are reasonably mature, we really don't have to worry about what's blessed as "standard" anymore. :-) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/bbccd486/attachment.htm From duncan.coutts at worc.ox.ac.uk Mon Dec 22 18:33:19 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Dec 22 18:25:52 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> <1229981795.5704.76.camel@localhost> Message-ID: <1229988799.5704.77.camel@localhost> On Mon, 2008-12-22 at 22:55 +0100, G?nther Schmidt wrote: > Hi, > > I put in on hpaste: > > http://hpaste.org/13264 > > slightly simplified Ok, that works fine when the action is something like threadDelay so it's clearly not blocking the UI. Duncan From redcom at fedoms.com Mon Dec 22 18:40:40 2008 From: redcom at fedoms.com (=?UTF-8?B?R8KfdWVudGhlciBTY2htaWR0?=) Date: Mon Dec 22 18:33:15 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <1229988799.5704.77.camel@localhost> References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> <1229981795.5704.76.camel@localhost> <1229988799.5704.77.camel@localhost> Message-ID: <49502578.8070107@fedoms.com> Hi Duncan, are you saying then that the db-code is what's blocking the UI? G?nther Duncan Coutts schrieb: > On Mon, 2008-12-22 at 22:55 +0100, G?nther Schmidt wrote: > >> Hi, >> >> I put in on hpaste: >> >> http://hpaste.org/13264 >> >> slightly simplified >> > > Ok, that works fine when the action is something like threadDelay so > it's clearly not blocking the UI. > > Duncan > > From eelco at lempsink.nl Mon Dec 22 19:14:27 2008 From: eelco at lempsink.nl (Eelco Lempsink) Date: Mon Dec 22 19:06:51 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <6f9f8f4a0812221014x26fbe18ev72a183df8481b9dc@mail.gmail.com> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> <20081221212333.GB25249@scytale.galois.com> <3d96ac180812211326s46953569wdce3c65f76abeb42@mail.gmail.com> <44D34BB4-5732-4E29-8684-5091FD502810@lempsink.nl> <6f9f8f4a0812221014x26fbe18ev72a183df8481b9dc@mail.gmail.com> Message-ID: <7418A9F8-640D-4A8E-9C65-117C5A192F35@lempsink.nl> On 22 dec 2008, at 19:14, Loup Vaillant wrote: > 2008/12/22 Eelco Lempsink : >> Hmm, right. I started on a thing in HAppS. See >> http://github.com/eelco/voting/ for the source code (contributors >> more than >> welcome!) and http://code.tupil.com/voting/ for a live demo. It >> relies >> heavily on javascript, needs some work on the UI and there are a >> lot of >> features that could be added, but "it works". > > Great. > Could it be further hacked to accept ties, as suggested by Sebastian? > Something like: > > thingie1 thingie1bis > thingie3 > thingie4 thingie4bis Yes. Done. It's quite tricky to get the dragging and dropping interface to work nice, but I think I'm getting close. If anybody with jQuery experience has some ideas how to improve it, please do :) -- Regards, Eelco Lempsink -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/d2b8806b/PGP.bin From jason.dusek at gmail.com Mon Dec 22 20:07:04 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Dec 22 19:59:24 2008 Subject: [Haskell-cafe] A hell of a question In-Reply-To: <7ca3f0160812220433y2491f5e2rffa678fed266e857@mail.gmail.com> References: <542709579B684DFEB328B6E788464AA1@bzdryk> <7ca3f0160812220433y2491f5e2rffa678fed266e857@mail.gmail.com> Message-ID: <42784f260812221707r23b7de61o7e8364a56f771642@mail.gmail.com> 2008/12/22 Luke Palmer : > Andrzej Jaworski > > First let me disassociate Haskell from Taoism... > I associate Haskell with Zen... The relationship between Taoism and Zen is actually very close. The notion of "stillness practice" is essentially Chinese. Indian schools of meditation and schools of Buddhism not originating in China, tend to emphasize an /object/ of meditation -- a God, a candle, what-have-you. The practice of "sitting still, doing nothing" finds its way into Buddhism when Chan Buddhism is formed in China. It is an adaption of a Taoist practice with a long history -- and in fact, Chan was seen as a Taoist renewal. It is Chan that makes its way to Japan to become the Zen we all know. -- Jason Dusek From jason.dusek at gmail.com Mon Dec 22 20:14:28 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Dec 22 20:06:47 2008 Subject: [Haskell-cafe] A hell of a question In-Reply-To: <542709579B684DFEB328B6E788464AA1@bzdryk> References: <542709579B684DFEB328B6E788464AA1@bzdryk> Message-ID: <42784f260812221714w5ca0899bg91ff8206e808a83e@mail.gmail.com> Andrzej Jaworski wrote: > First let me disassociate Haskell from Taoism which to may > taste has left us in an unhealthy climate. It suffices to say > that Taoism is a school of clever trics and cute aphorisms but > without the slightest attempt to explain or generalize let > alone produce an abstract idea or a system. That is why its > wisdom is non transferable in spite of majority of humans > desending from it. Taoist religion in China is very much a popular religion, closely associated with festivals, weddings and magic tricks. As a popular religion, Taoism is indeed deeply compromised; but then again, so is Zen in Japan, Christianity in Europe and indeed, most popular religions in the place where they became popular. As a philosophy, Taoism is more concerned with doubt than knowledge; with humility than pride of understanding; of course it makes litte "attempt to explain or generalize". An essential notion in Taoism is that signs and symbols do not communicate the truth -- to appreciate Taoist practice, you must engage in the practice of Taoism for a spell. Thus it is in practical arts -- Chinese medicine, Taiji, strategy -- that one comes to appreciate the Way and its Power. -- Jason Dusek From ryani.spam at gmail.com Mon Dec 22 20:14:33 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Dec 22 20:07:00 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> Message-ID: <2f9b2d30812221714m139f5f0n217e15e030253d6e@mail.gmail.com> You shouldn't need forkOS, but without -threaded (and related RTS switches to enable multithreading) I think you are sunk. Without enabling multithreading support, you are saying that your program (which might use concurrency features of Haskell) will run on a single OS thread. During a foreign call that never calls back into Haskell, then, there's no place for the RTS to pre-empt and switch back to Haskell code. It's kind of confusing with multiple things named threads; call a Haskell thread a "lightweight" thread, and an OS thread a "heavy" thread. Each heavy thread can either be executing Haskell lightweight threads, or inside a foreign out-call. Once you jump across to foreign-land, the heavy thread can't do anything (even for a "safe" out-call) until the out-call either makes an in-call back into Haskell code, or returns. Enabling -threaded allows the Haskell runtime to create more heavy threads; even without -threaded you can make as many lightweight threads as you like and the runtime will handle scheduling them for you; a heavy thread can carry many light threads. But a foreign call takes a whole heavy thread no matter what. -- ryan On Mon, Dec 22, 2008 at 1:12 PM, G?nther Schmidt wrote: > Hi guys, > > I just tried to forkIO-off the database code to keep the UI responsive using > Takusen with Sqlite this time. > > The problem persists though, the UI freezes. > > AFAIK the sqlite-Takusen code does not use unsafe ccall which would block > the thread, so that might not be the cause of the problem after all. > > Before you guys make the effort to "fix" this you might see if you can > reproduce the problem maybe uploading a 50 MB file into an Sqlite database, > for instance, or something else that will keep the database busy for some > time in a row. > > I did not use -threaded and forkOS though. > > G?nther > > > > Am 22.12.2008, 21:59 Uhr, schrieb John Goerzen : > >> On Mon, Dec 22, 2008 at 04:28:03PM -0000, Bayley, Alistair wrote: >>> >>> > From: haskell-cafe-bounces@haskell.org >>> > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt >>> > >>> > I understand that Takusen does not use "unsafe" calls and >>> > would like to >>> > try it with that one then, but haven't find enough docs yet >>> > on how to use >>> > Takusen. >>> >>> Not a lot of detailed examples exist for Takusen. I'm hoping the >>> documentation for Database.Enumerator is a reasonable place to start. >>> http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html >>> >>> I just reviewed the Takusen code and, for no apparent reason, the ODBC >>> module specifies unsafe for all of its FFI imports, but the other modules do >>> not (so they get the default, which I assume is safe). I also was not aware >>> of unsafe calls blocking other threads. I'll change the ODBC imports to be >>> safe (or rather, unspecified). >> >> Makes sense. I will make the similar change in all HDBC backends. >> >> -- John >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jonathanccast at fastmail.fm Mon Dec 22 20:23:09 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Mon Dec 22 20:15:30 2008 Subject: [Haskell-cafe] A hell of a question In-Reply-To: <42784f260812221714w5ca0899bg91ff8206e808a83e@mail.gmail.com> References: <542709579B684DFEB328B6E788464AA1@bzdryk> <42784f260812221714w5ca0899bg91ff8206e808a83e@mail.gmail.com> Message-ID: <1229995389.16426.16.camel@jonathans-macbook> On Mon, 2008-12-22 at 17:14 -0800, Jason Dusek wrote: > Andrzej Jaworski wrote: > > First let me disassociate Haskell from Taoism which to may > > taste has left us in an unhealthy climate. It suffices to say > > that Taoism is a school of clever trics and cute aphorisms but > > without the slightest attempt to explain or generalize let > > alone produce an abstract idea or a system. That is why its > > wisdom is non transferable in spite of majority of humans > > desending from it. > ... > Thus it is > in practical arts -- Chinese medicine, Taiji, strategy -- that > one comes to appreciate the Way and its Power. But nonetheless, Haskell is not a practical art, no more than theoretical physics or abstract algebra. jcc From jason.dusek at gmail.com Mon Dec 22 20:29:27 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Dec 22 20:21:46 2008 Subject: [Haskell-cafe] A hell of a question In-Reply-To: <1229995389.16426.16.camel@jonathans-macbook> References: <542709579B684DFEB328B6E788464AA1@bzdryk> <42784f260812221714w5ca0899bg91ff8206e808a83e@mail.gmail.com> <1229995389.16426.16.camel@jonathans-macbook> Message-ID: <42784f260812221729y5a994fc7n43ff2fd406d77361@mail.gmail.com> Jonathan Cast wrote: > Jason Dusek wrote: > > Thus it is in practical arts -- Chinese medicine, Taiji, > > strategy -- that one comes to appreciate the Way and its > > Power. > > But nonetheless, Haskell is not a practical art, no more than > theoretical physics or abstract algebra. I guess the question is whether we are treating Haskell as a means to appreciate Taoism or as Taoism itself. -- Jason Dusek From aslatter at gmail.com Mon Dec 22 20:52:40 2008 From: aslatter at gmail.com (Antoine Latter) Date: Mon Dec 22 20:45:01 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? In-Reply-To: <7ca3f0160812221529x52d9e55bt8b33a782574282b6@mail.gmail.com> References: <7ca3f0160812221529x52d9e55bt8b33a782574282b6@mail.gmail.com> Message-ID: <694519c50812221752q577afaf8h7793ad4c64eacf13@mail.gmail.com> 2008/12/22 Luke Palmer : > Yeah, it'd be useful. Doesn't really matter, though, because it's on > Hackage (http://hackage.haskell.org), so it's just a cabal install > MaybeT away. > Now that cabal and cabal-install are reasonably mature, we really don't have > to worry about what's blessed as "standard" anymore. :-) Although I still had to use my own because I wanted a MonadPlus instance. I would offer a patch, but since there's more than one useful MonadPlus instance for MaybeT it probably still wouldn't be right for everyone. -Antoine From rfhayes at reillyhayes.com Mon Dec 22 20:58:27 2008 From: rfhayes at reillyhayes.com (R Hayes) Date: Mon Dec 22 20:50:51 2008 Subject: [Haskell-cafe] Cabal Install & Links to Source from Haddock Docs In-Reply-To: <910ddf450812210111o5968073bm7d904107259ee7d6@mail.gmail.com> References: <910ddf450812210111o5968073bm7d904107259ee7d6@mail.gmail.com> Message-ID: Thank you. As it turns out, I was aware of that recipe. What I wanted was to be able to use cabal install's nice dependency following features and still get source links in my documentation. Personally, I feel that inclusion of source and docs should be the DEFAULT for cabal, as well as for binary distributions of ghc. -rhayes On Dec 21, 2008, at 1:11 AM, Thomas Hartman wrote: > the answer: not cabal install, just cabal. > > thartman@thartman-laptop:~/haskellInstalls/smallInstalls/ > pureMD5-0.2.3> > thartman@thartman-laptop:~/haskellInstalls/smallInstalls/ > pureMD5-0.2.3>cabal > --help | grep -i doc > haddock Generate Haddock HTML documentation. > thartman@thartman-laptop:~/haskellInstalls/smallInstalls/ > pureMD5-0.2.3>cabal > haddock --help | grep -i link > --hyperlink-source Hyperlink the documentation to the source > code > thartman@thartman-laptop:~/haskellInstalls/smallInstalls/ > pureMD5-0.2.3>cabal > haddock --hyperlink-source > > 2008/12/21 R Hayes : >> >> Is there a way I can get Haddock Docs WITH links to source (local) >> from >> modules installed with "cabal install xxx"? >> >> Getting the docs themselves is pretty easy by changing either >> ~/.cabal/config or using --enable-documentation. >> >> Automatically generating the source (colourised or not) and >> integrated links >> eludes me. >> >> -r >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From iavor.diatchki at gmail.com Mon Dec 22 20:59:19 2008 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Mon Dec 22 20:51:40 2008 Subject: [Haskell-cafe] Re: Is this related to monomorphism restriction? In-Reply-To: <7ca3f0160812211145v131c90ccsd84d5d51421af91c@mail.gmail.com> References: <4cf038ee0812201556m7fe8d3dfnd4a36bc8490caa3e@mail.gmail.com> <5ab17e790812211125x44f9c98el37b6bca5477ec66b@mail.gmail.com> <7ca3f0160812211145v131c90ccsd84d5d51421af91c@mail.gmail.com> Message-ID: <5ab17e790812221759x6f517b45ma72d3c7acfb40cb@mail.gmail.com> Hi, On Sun, Dec 21, 2008 at 11:45 AM, Luke Palmer wrote: > 2008/12/21 Iavor Diatchki >> >> >> g :: TestClass a => a -> Integer >> g = fst (a :: (a -> Integer, a -> Integer)) > > Which I believe needs to be written: > > g :: forall a. TestClass a => a -> Integer > g = fst (a :: (a -> Integer, a -> Integer)) > quite right! sorry for not testing my code. -iavor >> >> Here we are using another GHC extension called "scoped type variables" >> to associate the "a" in the type signature of "g" with the "a" in the >> type annotation for the value "a". >> >> Hope that this helps, >> Iavor >> >> >> >> >> On Sun, Dec 21, 2008 at 9:21 AM, Maur??cio >> wrote: >> >>> Why isn't the last line of this code allowed? >> >>> f :: (TestClass a) => a -> Integer >> >>> f = const 1 >> >>> a = (f,f) >> >>> g = fst a >> >>> The only thing I can think about is monomorphism >> >>> restriction, but it's allowed (...) >> > >> >> (...) The reason is that a has type >> >> a :: (TestClass a, TestClass b) => (a,b) >> >> and then when we take 'fst' of this value (as in g) we get >> > >> >> g :: (TestClass a, TestClass b) => a >> >> which is an ambiguous type, (...) >> > >> > Is there some version (i.e., set of extensions) of >> > Haskell where this would be allowed? >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > From kevin at ksvanhorn.com Mon Dec 22 21:18:20 2008 From: kevin at ksvanhorn.com (ksvanhorn) Date: Mon Dec 22 21:10:41 2008 Subject: [Haskell-cafe] Time for a new logo? In-Reply-To: <20081214211504.GO27904@scytale.galois.com> References: <20081214211504.GO27904@scytale.galois.com> Message-ID: <21138458.post@talk.nabble.com> Looking over the New_logo_ideas page, my vote is for the "snowflake" logo: http://haskell.org/sitewiki/images/9/98/Haskell-Symstar.png (I would simplify it, though, by removing the motto "pure - lazy - fun".) I like this logo because it works well on two different levels. For those in the know, the lambda and >>= symbols suggest monads and first-class functions, two important features of the language. For those unfamiliar with Haskell or functional programming, the logo still looks pretty cool and manages to suggest mathematical beauty. -- View this message in context: http://www.nabble.com/Time-for-a-new-logo--tp21004746p21138458.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From redcom at fedoms.com Mon Dec 22 21:30:06 2008 From: redcom at fedoms.com (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Dec 22 21:22:44 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <2f9b2d30812221714m139f5f0n217e15e030253d6e@mail.gmail.com> References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> <2f9b2d30812221714m139f5f0n217e15e030253d6e@mail.gmail.com> Message-ID: Hi Ryan, BINGO! that did it. Thanks a lot. It certainly works now, finally, eventhough I don't really know what the implications are. G?nther Am 23.12.2008, 02:14 Uhr, schrieb Ryan Ingram : > You shouldn't need forkOS, but without -threaded (and related RTS > switches to enable multithreading) I think you are sunk. Without > enabling multithreading support, you are saying that your program > (which might use concurrency features of Haskell) will run on a single > OS thread. During a foreign call that never calls back into Haskell, > then, there's no place for the RTS to pre-empt and switch back to > Haskell code. > > It's kind of confusing with multiple things named threads; call a > Haskell thread a "lightweight" thread, and an OS thread a "heavy" > thread. Each heavy thread can either be executing Haskell lightweight > threads, or inside a foreign out-call. Once you jump across to > foreign-land, the heavy thread can't do anything (even for a "safe" > out-call) until the out-call either makes an in-call back into Haskell > code, or returns. > > Enabling -threaded allows the Haskell runtime to create more heavy > threads; even without -threaded you can make as many lightweight > threads as you like and the runtime will handle scheduling them for > you; a heavy thread can carry many light threads. But a foreign call > takes a whole heavy thread no matter what. > > -- ryan > > On Mon, Dec 22, 2008 at 1:12 PM, G?nther Schmidt > wrote: >> Hi guys, >> >> I just tried to forkIO-off the database code to keep the UI responsive >> using >> Takusen with Sqlite this time. >> >> The problem persists though, the UI freezes. >> >> AFAIK the sqlite-Takusen code does not use unsafe ccall which would >> block >> the thread, so that might not be the cause of the problem after all. >> >> Before you guys make the effort to "fix" this you might see if you can >> reproduce the problem maybe uploading a 50 MB file into an Sqlite >> database, >> for instance, or something else that will keep the database busy for >> some >> time in a row. >> >> I did not use -threaded and forkOS though. >> >> G?nther >> >> >> >> Am 22.12.2008, 21:59 Uhr, schrieb John Goerzen : >> >>> On Mon, Dec 22, 2008 at 04:28:03PM -0000, Bayley, Alistair wrote: >>>> >>>> > From: haskell-cafe-bounces@haskell.org >>>> > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther >>>> Schmidt >>>> > >>>> > I understand that Takusen does not use "unsafe" calls and >>>> > would like to >>>> > try it with that one then, but haven't find enough docs yet >>>> > on how to use >>>> > Takusen. >>>> >>>> Not a lot of detailed examples exist for Takusen. I'm hoping the >>>> documentation for Database.Enumerator is a reasonable place to start. >>>> http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html >>>> >>>> I just reviewed the Takusen code and, for no apparent reason, the ODBC >>>> module specifies unsafe for all of its FFI imports, but the other >>>> modules do >>>> not (so they get the default, which I assume is safe). I also was not >>>> aware >>>> of unsafe calls blocking other threads. I'll change the ODBC imports >>>> to be >>>> safe (or rather, unspecified). >>> >>> Makes sense. I will make the similar change in all HDBC backends. >>> >>> -- John >>> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From jgoerzen at complete.org Mon Dec 22 21:53:14 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Dec 22 21:45:45 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> <2f9b2d30812221714m139f5f0n217e15e030253d6e@mail.gmail.com> Message-ID: <4950529A.30201@complete.org> G?nther Schmidt wrote: > Hi Ryan, > > BINGO! > > that did it. > > Thanks a lot. It certainly works now, finally, eventhough I don't really > know what the implications are. Did it still work with the unmodified HDBC as well? Just curious. -- John From 666wman at gmail.com Mon Dec 22 21:56:32 2008 From: 666wman at gmail.com (wman) Date: Mon Dec 22 21:48:52 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: <2f9b2d30812221714m139f5f0n217e15e030253d6e@mail.gmail.com> References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> <2f9b2d30812221714m139f5f0n217e15e030253d6e@mail.gmail.com> Message-ID: Thanks to you all for inspiration. My web app (which otherwise ran ok) was getting stuck while getting harassed by ab (apache-benchmark) after receiving some 800+ requests in short succession (not less, never gotten to 900, what was weird that running like 500 reqs - pause - 500 reqs ... went ok). After compiling with -threaded and running with +RTS -N2 it handles 10k+ requests (with 10 concurrent request running at once) without missing a beat. Well, at least I double checked everything else ;-))) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/2d3dfa21/attachment.htm From artyom.shalkhakov at gmail.com Mon Dec 22 22:45:12 2008 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Mon Dec 22 22:37:32 2008 Subject: [Haskell-cafe] Takusen In-Reply-To: References: Message-ID: <2076f2f90812221945n44c3b4agc9b7109cc5eeb4da@mail.gmail.com> Hi G?nther, 2008/12/22 G?nther Schmidt : > where can I find some sample code or other examples to familiarize me with > Takusen? The best resource I've found is: http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html Cheers, Artyom Shalkhakov. From 666wman at gmail.com Mon Dec 22 23:21:56 2008 From: 666wman at gmail.com (wman) Date: Mon Dec 22 23:14:16 2008 Subject: [Haskell-cafe] intercalate and (byte)strings Message-ID: I encountered the following code : -- B == Data.ByteString ; L == Data.ByteString.Lazy contents' = B.intercalate B.empty $ L.toChunks contents with a previously unencountered function intercalate. A quick google query later i knew that it's just intersperse & concat nicely bundled and started wondering why anybody would do this, as simple contents' = B.concat $ L.toChunks contents would do (probably nearly) the same. The only thing I am able to come up with is that it somehow helps streamline the memory usage (if it has some meaning). Is there some reason to use intercalate instead of concat (probably when dealing with non-lazy bytestrings) ? Thx, wman. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/35b79306/attachment.htm From vigalchin at gmail.com Tue Dec 23 01:34:43 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 23 01:27:03 2008 Subject: [Haskell-cafe] [Byte8] <-> ByteString Message-ID: <5ae4f2ba0812222234j13625e39i59fb4794d8e4e844@mail.gmail.com> Hello, I have been reading through Data->ByteString. What is the is most elegant and efficient way to map/unmap [Byte8] <-> ByteString? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/c6275fe6/attachment.htm From lrpalmer at gmail.com Tue Dec 23 01:49:02 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Dec 23 01:41:22 2008 Subject: [Haskell-cafe] [Byte8] <-> ByteString In-Reply-To: <5ae4f2ba0812222234j13625e39i59fb4794d8e4e844@mail.gmail.com> References: <5ae4f2ba0812222234j13625e39i59fb4794d8e4e844@mail.gmail.com> Message-ID: <7ca3f0160812222249y1e7f1344x9d55eece1c63ce14@mail.gmail.com> 2008/12/22 Galchin, Vasili > Hello, > > I have been reading through Data->ByteString. What is the is most > elegant and efficient way to map/unmap [Byte8] <-> ByteString? pack and unpack. You might need a fromIntegral in there, depending on whether Byte8 and Word8 are the same. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/39ee4b0e/attachment-0001.htm From lrpalmer at gmail.com Tue Dec 23 01:53:11 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Dec 23 01:45:31 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? In-Reply-To: <694519c50812221752q577afaf8h7793ad4c64eacf13@mail.gmail.com> References: <7ca3f0160812221529x52d9e55bt8b33a782574282b6@mail.gmail.com> <694519c50812221752q577afaf8h7793ad4c64eacf13@mail.gmail.com> Message-ID: <7ca3f0160812222253p62c66e44odea1d3614e5a393b@mail.gmail.com> On Mon, Dec 22, 2008 at 6:52 PM, Antoine Latter wrote: > 2008/12/22 Luke Palmer : > > Yeah, it'd be useful. Doesn't really matter, though, because it's on > > Hackage (http://hackage.haskell.org), so it's just a cabal install > > MaybeT away. > > Now that cabal and cabal-install are reasonably mature, we really don't > have > > to worry about what's blessed as "standard" anymore. :-) > > Although I still had to use my own because I wanted a MonadPlus > instance. I would offer a patch, but since there's more than one > useful MonadPlus instance for MaybeT it probably still wouldn't be > right for everyone. There are? The only two I can think of are the left-biased and its dual, in which case the convention is to choose the left-biased one. Is there another? Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081222/54797008/attachment.htm From jgmorris at cecs.pdx.edu Tue Dec 23 02:01:33 2008 From: jgmorris at cecs.pdx.edu (J. Garrett Morris) Date: Tue Dec 23 01:53:52 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? In-Reply-To: References: Message-ID: <6cf91caa0812222301v344ee4fai1f672b5869fe4ad8@mail.gmail.com> On Mon, Dec 22, 2008 at 2:31 PM, Brian Hurt wrote: > But I'm wondering why it's not in the standard library. The standards > committee just hasn't gotten around to it yet? Or was there some discussion > of this in the past on some (public) maillist, that my admittedly shallow > googling failed to uncover, that someone could point me at? It's equivalent to ErrorT () - but ErrorT String is almost always a better option anyway. /g -- I am in here From vigalchin at gmail.com Tue Dec 23 02:12:47 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Dec 23 02:05:06 2008 Subject: [Haskell-cafe] [Byte8] <-> ByteString In-Reply-To: <7ca3f0160812222249y1e7f1344x9d55eece1c63ce14@mail.gmail.com> References: <5ae4f2ba0812222234j13625e39i59fb4794d8e4e844@mail.gmail.com> <7ca3f0160812222249y1e7f1344x9d55eece1c63ce14@mail.gmail.com> Message-ID: <5ae4f2ba0812222312g6236ff78u4f535cc5b4b52374@mail.gmail.com> sorry actually ByteString -> [Word8].... On Tue, Dec 23, 2008 at 12:49 AM, Luke Palmer wrote: > 2008/12/22 Galchin, Vasili > >> Hello, >> >> I have been reading through Data->ByteString. What is the is most >> elegant and efficient way to map/unmap [Byte8] <-> ByteString? > > > pack and unpack. You might need a fromIntegral in there, depending on > whether Byte8 and Word8 are the same. > > Luke > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/6a8a115f/attachment.htm From oleg at okmij.org Tue Dec 23 03:45:33 2008 From: oleg at okmij.org (oleg@okmij.org) Date: Tue Dec 23 03:38:42 2008 Subject: [Haskell-cafe] Re: understanding enumerator/iteratee Message-ID: <20081223084533.A6BDBAB11@Adric.metnet.fnmoc.navy.mil> Artyom Shalkhakov wrote > I would say that it [iteratee] just tells us how to react to various forms of > input. :) This is much like the function you pass to foldr. Precisely. To sum up all elements of Data.Map, we do Map.fold (+) 0 mp to sum up all elements of a set we do Set.fold (+) 0 st ditto for any other foldable data structure. Clearly the function that sums the current element with the accumulator, (+), doesn't know or care from which collection the elements are coming from. The initial seed, 0, is again unaware of the collection. Iteratee is indeed the function that you pass to fold (combined with the seed for practical reasons). One may conceptually consider iteratee to be a pair of the function to feed to fold, and the initial seed (the accumulator in the above example). That achieves the separation of concerns: fold (aka, enumerator) has the intimate knowledge of the collection and how to get to the next element; iteratee knows what to do with the current element. From ndmitchell at gmail.com Tue Dec 23 03:59:27 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Dec 23 03:51:46 2008 Subject: [Haskell-cafe] intercalate and (byte)strings In-Reply-To: References: Message-ID: <404396ef0812230059v6a75a062l32a64b514dd1495d@mail.gmail.com> Hi wman, > -- B == Data.ByteString ; L == Data.ByteString.Lazy > contents' = B.intercalate B.empty $ L.toChunks contents > > with a previously unencountered function intercalate. A quick google query > later i knew that it's just intersperse & concat nicely bundled and started > wondering why anybody would do this, as simple > > contents' = B.concat $ L.toChunks contents > > would do (probably nearly) the same. The only thing I am able to come up > with is that it somehow helps streamline the memory usage (if it has some > meaning). > > Is there some reason to use intercalate instead of concat > (probably when dealing with non-lazy bytestrings) ? If they do the same thing, no - and I'm pretty sure they are identical. If a much more efficient version of concat was intercalate empty, then the bytestring authors would have just defined: concat = interacalate empty It's best to use the clearest code, always. Performance is something for library authors. (It is sometimes acceptable to use the non clearest code for performance, but it is 100% mandatory to add a comment to that effect!) Thanks Neil From fruehr at willamette.edu Tue Dec 23 04:10:29 2008 From: fruehr at willamette.edu (Fritz Ruehr) Date: Tue Dec 23 04:02:53 2008 Subject: [Haskell-cafe] New Haskell logo contest Message-ID: I think this logo contest is a great idea. I submitted my "classy Haskell" logo from the merch. page, but I have to admit I like some of the other ones on the submission page a whole lot. Hey, *here's* an idea: maybe whoever wins the logo contest has to take over management of the Haskell merchandise page on CafePress! :) -- Fritz Ruehr From mle+cl at mega-nerd.com Tue Dec 23 04:12:20 2008 From: mle+cl at mega-nerd.com (Erik de Castro Lopo) Date: Tue Dec 23 04:04:44 2008 Subject: [Haskell-cafe] Parsec question Message-ID: <20081223201220.98a4cbc0.mle+cl@mega-nerd.com> Hi all, I'm rather new to Haskell and I'm diving right into the deep end writing a parser using Parsec. In particular I'm using Text.ParserCombinators.Parsec.Language to do some of the heavy lifting and have this: import qualified Text.ParserCombinators.Parsec.Language as L import qualified Text.ParserCombinators.Parsec.Token as T lexer = T.makeTokenParser L.emptyDef { L.identStart = letter <|> char '_', L.identLetter = alphaNum <|> char '_', .... identifier :: CharParser st String identifier = T.identifier lexer and now I need to parse things "this.that.the.other". I'd like to have a function with the following signature: qualifiedIdentifier :: CharParser st [ String ] which should return [ "this", "that", "the", "other" ] and write it in terms of identifier and thats where I'm stuck. Anyone care to whack me with the cluestick? Cheers, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "If you don't have freedom as a principle, you can never see a reason not to make an exception." -- Richard Stallman. From ron at gamr7.com Tue Dec 23 04:14:45 2008 From: ron at gamr7.com (Ron de Bruijn) Date: Tue Dec 23 04:05:52 2008 Subject: [Haskell-cafe] Initializing GHC from Python Message-ID: <4950AC05.9060105@gamr7.com> Hi, We have just published a small article on how one can initialize GHC from Python, with only optional use of C. You can read it at http://gamr7.com/blog/?p=65 . Best regards, Ron de Bruijn From mle+cl at mega-nerd.com Tue Dec 23 05:58:38 2008 From: mle+cl at mega-nerd.com (Erik de Castro Lopo) Date: Tue Dec 23 05:50:59 2008 Subject: [Haskell-cafe] Parsec question In-Reply-To: <20081223201220.98a4cbc0.mle+cl@mega-nerd.com> References: <20081223201220.98a4cbc0.mle+cl@mega-nerd.com> Message-ID: <20081223215838.99d50aa1.mle+cl@mega-nerd.com> Erik de Castro Lopo wrote: > qualifiedIdentifier :: CharParser st [ String ] Ahh, figured it out myself: qualifiedIdentifier :: CharParser st [ String ] qualifiedIdentifier = do i <- identifier r <- dotIdentifier return (i : r) where dotIdentifier = do char '.' i <- identifier r <- dotIdentifier return (i : r) <|> return [] Does that look sane to people who know Haskell and Parsec better than me? Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- The Earth is around 70% water. Fish rule the seas. Humans are over 90% water. It's only a matter of time. From wqeqweuqy at hotmail.com Tue Dec 23 06:00:07 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Tue Dec 23 05:52:41 2008 Subject: [Haskell-cafe] Re: concurrent haskell: thread priorities In-Reply-To: <11545907.20081222231446@gmail.com> References: <11545907.20081222231446@gmail.com> Message-ID: Bulat Ziganshin wrote: > Hello Neal, > > Monday, December 22, 2008, 11:07:32 PM, you wrote: > >> The threaded RT creates an OS thread for each CPU/core on the system and >> uses them to multiplex userland threads. These are context switched >> whenever they block/yield/gc and no priorities can be assigned. > > not exactly. amount of OS threads created controlled by +RTS -N option > to the program; unless program has special function that RTS calls to > set up this value > > they are switched on every minor GC which by default occurs after > each 256kb allocated which is rather frequent event > >> It seems like we could get some priority based scheduling (and still be >> slackers) if we allow marked green threads to be strictly associated >> with a specific OS thread (forkChildIO?). > > forkOS creates new haskell thread and new OS thread specially for it > The docs say that the forkOS thread is still scheduled by the Haskell RT though. What would happen if you bump its priority through FFI? What about this scenario: forkOS = OS thread A1, Haskell Thread A2 forkIO = Haskell thread B Could thread B potentially be run on thread A1? Would the RT yield thread A2 to give time to another Haskell thread? From Alistair.Bayley at invesco.com Tue Dec 23 06:07:18 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Tue Dec 23 05:59:39 2008 Subject: [Haskell-cafe] Problems Installing Takusen with Sqlite Backend In-Reply-To: References: <1229897782.4495.7.camel@localhost.localdomain><1229899191.4495.13.camel@localhost.localdomain><20081221230712.GE25249@scytale.galois.com><20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk><1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org><125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911025D74@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt > > what does it take to install Takusen on Win32 with Sqlite backend? > > I did manage to install *plain* Takusen via cabal install by > downgrading > to Cabal-1.4 but when I want to > > cabal-install takusen -fsqlite > > it complains about a missing sqlite3. Setup.hs tries to find the location of your sqlite installation by looking for sqlite3.exe, so you need this (and sqlite.dll) in your path. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From redcom at fedoms.com Tue Dec 23 06:26:53 2008 From: redcom at fedoms.com (=?UTF-8?B?R8KfdWVudGhlciBTY2htaWR0?=) Date: Tue Dec 23 06:19:16 2008 Subject: [Haskell-cafe] Problems Installing Takusen with Sqlite Backend In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911025D74@GBLONXMB02.corp.amvescap.net> References: <1229897782.4495.7.camel@localhost.localdomain><1229899191.4495.13.camel@localhost.localdomain><20081221230712.GE25249@scytale.galois.com><20081222103051.4fa2f917.Malcolm.Wallace@cs.york.ac.uk><1229946142.5704.57.camel@localhost> <494FA112.60904@complete.org><125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <125EACD0CAE4D24ABDB4D148C4593DA911025D74@GBLONXMB02.corp.amvescap.net> Message-ID: <4950CAFD.9030507@fedoms.com> Thanks Alistair, inspiration had stuck me meanwhile and that's exactly what I did. G?nther Bayley, Alistair schrieb: >> From: haskell-cafe-bounces@haskell.org >> [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt >> >> what does it take to install Takusen on Win32 with Sqlite backend? >> >> I did manage to install *plain* Takusen via cabal install by >> downgrading >> to Cabal-1.4 but when I want to >> >> cabal-install takusen -fsqlite >> >> it complains about a missing sqlite3. >> > > Setup.hs tries to find the location of your sqlite installation by looking for sqlite3.exe, so you need this (and sqlite.dll) in your path. > > Alistair > ***************************************************************** > Confidentiality Note: The information contained in this message, > and any attachments, may contain confidential and/or privileged > material. It is intended solely for the person(s) or entity to > which it is addressed. Any review, retransmission, dissemination, > or taking of any action in reliance upon this information by > persons or entities other than the intended recipient(s) is > prohibited. If you received this in error, please contact the > sender and delete the material from any computer. > ***************************************************************** > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/bcfeaea0/attachment.htm From benjovi at gmx.net Tue Dec 23 07:25:49 2008 From: benjovi at gmx.net (Benedikt Huber) Date: Tue Dec 23 07:18:10 2008 Subject: [Haskell-cafe] Re: Parsec question In-Reply-To: <20081223215838.99d50aa1.mle+cl@mega-nerd.com> References: <20081223201220.98a4cbc0.mle+cl@mega-nerd.com> <20081223215838.99d50aa1.mle+cl@mega-nerd.com> Message-ID: <4950D8CD.1090900@gmx.net> Erik de Castro Lopo schrieb: > Erik de Castro Lopo wrote: > >> qualifiedIdentifier :: CharParser st [ String ] > > Ahh, figured it out myself: > > qualifiedIdentifier :: CharParser st [ String ] > qualifiedIdentifier = do > i <- identifier > r <- dotIdentifier > return (i : r) > where > dotIdentifier = do > char '.' > i <- identifier > r <- dotIdentifier > return (i : r) > <|> return [] > > Does that look sane to people who know Haskell and Parsec > better than me? Hi Erik, have a look at the module Text.ParserCombinators.Parsec.Combinator. Those functions should help you to build up parsers from smaller building blocks. Using sepBy1, the above parser can be written as dot = T.dot lexer qualifiedIdentifier = sepBy1 identifier dot benedikt From duncan.coutts at worc.ox.ac.uk Tue Dec 23 07:38:51 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 23 07:31:22 2008 Subject: [Haskell-cafe] Cabal Install & Links to Source from Haddock Docs In-Reply-To: References: <910ddf450812210111o5968073bm7d904107259ee7d6@mail.gmail.com> Message-ID: <1230035931.11245.3.camel@localhost> On Mon, 2008-12-22 at 17:58 -0800, R Hayes wrote: > Thank you. As it turns out, I was aware of that recipe. What I > wanted was to be able to use cabal install's nice dependency following > features and still get source links in my documentation. Due to popular demand we quickly added the --enable-documentation flag but did not manage to agree a design for exposing the other haddock/documentation flags via cabal install. We'd appreciate if you could add your suggestions for the design of the command line interface to this ticket: http://hackage.haskell.org/trac/hackage/ticket/206 > Personally, I feel that inclusion of source and docs should be the > DEFAULT for cabal, as well as for binary distributions of ghc. You can set it as a default in the ~/.cabal/config file. Duncan From mle+cl at mega-nerd.com Tue Dec 23 07:58:30 2008 From: mle+cl at mega-nerd.com (Erik de Castro Lopo) Date: Tue Dec 23 07:50:52 2008 Subject: [Haskell-cafe] Re: Parsec question In-Reply-To: <4950D8CD.1090900@gmx.net> References: <20081223201220.98a4cbc0.mle+cl@mega-nerd.com> <20081223215838.99d50aa1.mle+cl@mega-nerd.com> <4950D8CD.1090900@gmx.net> Message-ID: <20081223235830.23bc19f2.mle+cl@mega-nerd.com> Benedikt Huber wrote: > have a look at the module Text.ParserCombinators.Parsec.Combinator. > Those functions should help you to build up parsers from smaller > building blocks. > > Using sepBy1, the above parser can be written as > > dot = T.dot lexer > qualifiedIdentifier = sepBy1 identifier dot WOW!!!! That is really impressive! Thanks, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "One serious obstacle to the adoption of good programming languages is the notion that everything has to be sacrificed for speed. In computer languages as in life, speed kills." -- Mike Vanier From duncan.coutts at worc.ox.ac.uk Tue Dec 23 09:02:42 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 23 08:55:14 2008 Subject: [Haskell-cafe] Re: Threads with high CPU usage In-Reply-To: References: <494FA112.60904@complete.org> <125EACD0CAE4D24ABDB4D148C4593DA911025D72@GBLONXMB02.corp.amvescap.net> <20081222205916.GA17953@hustlerturf.com> <2f9b2d30812221714m139f5f0n217e15e030253d6e@mail.gmail.com> Message-ID: <1230040962.11245.18.camel@localhost> On Tue, 2008-12-23 at 03:56 +0100, wman wrote: > Thanks to you all for inspiration. > > My web app (which otherwise ran ok) was getting stuck while getting > harassed by ab (apache-benchmark) after receiving some 800+ requests > in short succession (not less, never gotten to 900, what was weird > that running like 500 reqs - pause - 500 reqs ... went ok). > > After compiling with -threaded and running with +RTS -N2 it handles > 10k+ requests (with 10 concurrent request running at once) without > missing a beat. How about compiled with -threaded and running with just +RTS -N1 ? I would expect the crucial thing is the -threaded not the number of cpus running Haskell code concurrently (-threaded uses a pool of OS threads to make blocking foreign calls effectively non-blocking). Duncan From hthiel.char at zonnet.nl Tue Dec 23 09:16:29 2008 From: hthiel.char at zonnet.nl (Hans van Thiel) Date: Tue Dec 23 09:07:56 2008 Subject: [Haskell-cafe] What are side effects in Haskell? Message-ID: <1230041789.3231.13.camel@dhcppc0> Hello All, I just saw somewhere that one of the purposes of monads is to capture side effects. I understand what a side effect is in C, for example. Say you want to switch the contents of two variables. Then you need a third temporary variable to store an intermediate result. If this is global, then it will be changed by the operation. But what is a side effect in an fp language like Haskell? As a follow up, I understand why an IO action like getLine or getChar is not a function; its results can be different for different calls. But why not have something like getChar c or getLine str? The types of c or str are pretty clear, aren't they? Just something that's been puzzling me for some time now...thanks. Regards, Hans van Thiel From duncan.coutts at worc.ox.ac.uk Tue Dec 23 09:16:37 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 23 09:09:07 2008 Subject: [Haskell-cafe] [Byte8] <-> ByteString In-Reply-To: <5ae4f2ba0812222234j13625e39i59fb4794d8e4e844@mail.gmail.com> References: <5ae4f2ba0812222234j13625e39i59fb4794d8e4e844@mail.gmail.com> Message-ID: <1230041797.11245.22.camel@localhost> On Tue, 2008-12-23 at 00:34 -0600, Galchin, Vasili wrote: > Hello, > > I have been reading through Data->ByteString. What is the is > most elegant and efficient way to map/unmap [Byte8] <-> ByteString? Hoogle is your friend! http://haskell.org/hoogle/ [Word8] -> ByteString http://haskell.org/hoogle/?hoogle=%5BWord8%5D+-%3E+ByteString ByteString -> [Word8] http://haskell.org/hoogle/?hoogle=ByteString+-%3E+%5BWord8%5D Duncan From duncan.coutts at worc.ox.ac.uk Tue Dec 23 09:21:37 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 23 09:14:07 2008 Subject: [Haskell-cafe] intercalate and (byte)strings In-Reply-To: References: Message-ID: <1230042097.11245.23.camel@localhost> On Tue, 2008-12-23 at 05:21 +0100, wman wrote: > I encountered the following code : > > -- B == Data.ByteString ; L == Data.ByteString.Lazy > contents' = B.intercalate B.empty $ L.toChunks contents > > with a previously unencountered function intercalate. A quick google > query later i knew that it's just intersperse & concat nicely bundled > and started wondering why anybody would do this, as simple > > contents' = B.concat $ L.toChunks contents > > would do (probably nearly) the same. The only thing I am able to come > up with is that it somehow helps streamline the memory usage (if it > has some meaning). > > Is there some reason to use intercalate instead of > concat (probably when dealing with non-lazy bytestrings) ? I cannot see any advantage. I would be extremely surprised if the more obscure version was faster. Duncan From 666wman at gmail.com Tue Dec 23 10:06:38 2008 From: 666wman at gmail.com (wman) Date: Tue Dec 23 09:58:56 2008 Subject: [Haskell-cafe] intercalate and (byte)strings In-Reply-To: <1230042097.11245.23.camel@localhost> References: <1230042097.11245.23.camel@localhost> Message-ID: Thank you, guys, i somehow got the impression that there has to be some meaning to this. It seemed unprobable, but why would anybody write it like that if there weren't some reason to it ? ;-))) Have a nice holidays, btw. Cheers, wman. On Tue, Dec 23, 2008 at 3:21 PM, Duncan Coutts wrote: > On Tue, 2008-12-23 at 05:21 +0100, wman wrote: > > I encountered the following code : > > > > -- B == Data.ByteString ; L == Data.ByteString.Lazy > > contents' = B.intercalate B.empty $ L.toChunks contents > > > > with a previously unencountered function intercalate. A quick google > > query later i knew that it's just intersperse & concat nicely bundled > > and started wondering why anybody would do this, as simple > > > > contents' = B.concat $ L.toChunks contents > > > > would do (probably nearly) the same. The only thing I am able to come > > up with is that it somehow helps streamline the memory usage (if it > > has some meaning). > > > > Is there some reason to use intercalate instead of > > concat (probably when dealing with non-lazy bytestrings) ? > > I cannot see any advantage. I would be extremely surprised if the more > obscure version was faster. > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/17cb0f87/attachment.htm From cristiano.paris at gmail.com Tue Dec 23 10:09:37 2008 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Tue Dec 23 10:01:55 2008 Subject: [Haskell-cafe] What are side effects in Haskell? In-Reply-To: <1230041789.3231.13.camel@dhcppc0> References: <1230041789.3231.13.camel@dhcppc0> Message-ID: On Tue, Dec 23, 2008 at 3:16 PM, Hans van Thiel wrote: > Hello All, > > I just saw somewhere that one of the purposes of monads is to capture > side effects. I understand what a side effect is in C, for example. Say > you want to switch the contents of two variables. Then you need a third > temporary variable to store an intermediate result. If this is global, > then it will be changed by the operation. > But what is a side effect in an fp language like Haskell? Generally speaking, you have no side effects whenever the only result of a function is the return of its outcome, in contrast with those changing something else (like updating a database, a file, the screen output and so on). In Haskell you can't write an effectful function because its scope is limited to the function's local bindings (i.e. its input arguments and any other name locally defined in its definition). If you want something "global" to affect a function's operations you have to pass it, either explicitly (pure functions) or implicitly (monadic actions). Likewise, if you want to persist an effect after a function's execution you have to gather it from the returned value and feed it to any other subsequent function calls. Though, notice that there are exceptions to the above rule (namely unsafePerformIO) but they are kind of tricks. > As a follow up, I understand why an IO action like getLine or getChar is > not a function; its results can be different for different calls. Anything in Haskell is a function: getLine and getChar ARE functions returning actions to be executed in the IO Monad, i.e. at run-time. > But > why not have something like getChar c or getLine str? The types of c or > str are pretty clear, aren't they? Because c are not effected by getChar or getLine, as they are outside the scope of the functions. What you are really passing to getChar/getLine is just the content of c and str which goes out of the scope just after the functions have finished executing. Hope this helps. Cristiano From haskell at list.mightyreason.com Tue Dec 23 10:26:10 2008 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Dec 23 10:18:41 2008 Subject: [Haskell-cafe] Re: What are side effects in Haskell? In-Reply-To: <1230041789.3231.13.camel@dhcppc0> References: <1230041789.3231.13.camel@dhcppc0> Message-ID: <49510312.3050109@list.mightyreason.com> Hans van Thiel wrote: > I just saw somewhere that one of the purposes of monads is to capture > side effects. There are a few things that have "side effects". The best way to capture this is to see that there are both (1) commands whose result depends on some external state (2) commands which alter that state The (2) group has side effects, and (1) is affected by them. The order in which (1) and (2) are performed matters. commands that evaluate to different things based on environment/history/input: * reading from memory location or reference * reading from a file or network stream or sensor (e.g. keyboard or mouse) * a random or pseudo-random number generator commands which affect the environment * writing to a memory location or reference * writing to a file or network * changing the display buffer (i.e. windows on the screen) command which are both (1) and (2), often because they might fail: * creating or deleting a file * obtaining a lock or semaphore * interacting with a message queue So allocating a mutable variable and writing to it are side-effect operations which have to be carefully ordered with the corresponding reads. Things without side effects are the immutable bindings produced by "let/where", and application of functions. This is independent of being lazy or strict. Note that "putStr :: String -> IO ()" is a function, and as such it is a pure value. "putString ['a','b','\n']" is a pure value of "IO ()". Performing this command in the IO monad has side effects. The fact that functions like putStr and things with types of "IO ()" are pure value means that they can be produced and passed around is powerful way of working. It is possible to create objects in C++/Java which encapsulate an operation, but it takes more syntax. From aslatter at gmail.com Tue Dec 23 10:39:24 2008 From: aslatter at gmail.com (Antoine Latter) Date: Tue Dec 23 10:31:42 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? In-Reply-To: <7ca3f0160812222253p62c66e44odea1d3614e5a393b@mail.gmail.com> References: <7ca3f0160812221529x52d9e55bt8b33a782574282b6@mail.gmail.com> <694519c50812221752q577afaf8h7793ad4c64eacf13@mail.gmail.com> <7ca3f0160812222253p62c66e44odea1d3614e5a393b@mail.gmail.com> Message-ID: <694519c50812230739o5a9ed34ak2c223ba3037af0a8@mail.gmail.com> On Tue, Dec 23, 2008 at 12:53 AM, Luke Palmer wrote: > On Mon, Dec 22, 2008 at 6:52 PM, Antoine Latter wrote: >> Although I still had to use my own because I wanted a MonadPlus >> instance. I would offer a patch, but since there's more than one >> useful MonadPlus instance for MaybeT it probably still wouldn't be >> right for everyone. > > There are? The only two I can think of are the left-biased and its dual, in > which case the convention is to choose the left-biased one. Is there > another? > It's a monad-transformer, so the MonadPlus/Alternative instance could either apply Maybe semantics or lift the behavior of whatever it wraps. -Antoine From cetin.sert at gmail.com Tue Dec 23 11:27:44 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Tue Dec 23 11:21:02 2008 Subject: [Haskell-cafe] cabal, multi-file applications Message-ID: <1ff5dedc0812230827l32a4fdc4n1e9c5c42cecbb972@mail.gmail.com> Hi, I get the following error message: cetin@unique:~/lab/test/qths/hnm$ make configure runhaskell Setup.hs configure Configuring HNM-0.2... cetin@unique:~/lab/test/qths/hnm$ make build runhaskell Setup.hs build Preprocessing library HNM-0.2... Preprocessing executables for HNM-0.2... Building HNM-0.2... demo3.hs:4:7: Could not find module `HNM.WLAN': Use -v to see a list of the files searched for. make: *** [build] Error 1 when I try to build the following program: http://sert.homedns.org/hs/hnm/ http://sert.homedns.org/hs/hnm/hnm.cabal How can I tell in my cabal file that wlan.hs should be built first than settings.hs than demo3.hs? Best Regards, Cetin Sert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/b08107d4/attachment.htm From gwern0 at gmail.com Tue Dec 23 11:59:56 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Dec 23 11:52:40 2008 Subject: [Haskell-cafe] cabal, multi-file applications In-Reply-To: <1ff5dedc0812230827l32a4fdc4n1e9c5c42cecbb972@mail.gmail.com> References: <1ff5dedc0812230827l32a4fdc4n1e9c5c42cecbb972@mail.gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 2008/12/23 Cetin Sert : > Hi, > > I get the following error message: > > cetin@unique:~/lab/test/qths/hnm$ make configure > runhaskell Setup.hs configure > Configuring HNM-0.2... > cetin@unique:~/lab/test/qths/hnm$ make build > runhaskell Setup.hs build > Preprocessing library HNM-0.2... > Preprocessing executables for HNM-0.2... > Building HNM-0.2... > > demo3.hs:4:7: > Could not find module `HNM.WLAN': > Use -v to see a list of the files searched for. > make: *** [build] Error 1 > > when I try to build the following program: > http://sert.homedns.org/hs/hnm/ > http://sert.homedns.org/hs/hnm/hnm.cabal > > How can I tell in my cabal file that wlan.hs should be built first than > settings.hs than demo3.hs? > > Best Regards, > Cetin Sert You need some changes like this (as a Darcs patch): adddir ./HNM move ./settings.hs ./HNM/Settings.hs move ./wlan.hs ./HNM/WLAN.hs hunk ./hnm.cabal 3 - -Description: Happy Network Manager - -License: BSD +Synopsis: Happy Network Manager +Category: Network, System +homepage: http://sert.homedns.org/hs/hnm/ +License: BSD3 hunk ./hnm.cabal 9 - -Maintainer: cetin@sertcom.de +Maintainer: hunk ./hnm.cabal 13 +data-files: settings.conf + hunk ./hnm.cabal 17 - -ghc-options: -O3 -fglasgow-exts +other-modules: HNM.WLAN, HNM.Settings +ghc-options: -O2 -fglasgow-exts Note that -O3 is counterintuitively no better than -O2, and may be worse. You should probably change the -fglasgow-exts to individual per-file {-# LANGUAGE #-} pragmas. And you don't declare all your dependencies, for example I see Gtk2Hs imports, but no declarations in build-depends:. To solve your problem, you need to put the module names in other-modules:, but your modules are at wrong names. If a module's name is HNM.Settings, then it needs to be at Settings.hs. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAklRGQcACgkQvpDo5Pfl1oLDHgCfcRswCMsUUPZLknvUrENM/MmD U7gAoIBq0CXXU6XHKn0L4kGi45zENNJ3 =txxi -----END PGP SIGNATURE----- From duncan.coutts at worc.ox.ac.uk Tue Dec 23 12:13:37 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Dec 23 12:06:08 2008 Subject: [Haskell-cafe] cabal, multi-file applications In-Reply-To: <1ff5dedc0812230827l32a4fdc4n1e9c5c42cecbb972@mail.gmail.com> References: <1ff5dedc0812230827l32a4fdc4n1e9c5c42cecbb972@mail.gmail.com> Message-ID: <1230052417.11245.37.camel@localhost> On Tue, 2008-12-23 at 17:27 +0100, Cetin Sert wrote: > when I try to build the following program: > http://sert.homedns.org/hs/hnm/ > http://sert.homedns.org/hs/hnm/hnm.cabal > > How can I tell in my cabal file that wlan.hs should be built first > than settings.hs than demo3.hs? You need to follow the standard file name convention for modules. The module HNM.WLAN needs to be in the file HNM/WLAN.hs rather than wlan.hs. Similarly you will need to rename settings.hs to HNM/Settings.hs. That way cabal and ghc will be able to find the files. In the .cabal file you do not need these fields: Extra-Source-Files: wlan.hs, settings.hs HS-Source-Dirs: . Instead you should use: other-modules: HNM.WLAN, HNM.Settings Looking at: ghc-options: -fglasgow-exts -O3 --make you do not need '--make'. Using 'cabal check' or 'sdist' will have other suggestions for better portability and recommended practise. Duncan From pkeir at dcs.gla.ac.uk Tue Dec 23 13:27:00 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Tue Dec 23 13:19:20 2008 Subject: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED] References: <3CDFB8AFEA98E34CB599475AB11589C81C7190@EX2.ad.dcs.gla.ac.uk> <494BCEF6.8090707@pikewerks.com> <1229709140.10115.782.camel@localhost> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCB2F@EX2.ad.dcs.gla.ac.uk> Hi Duncan, I'm following the story regarding (parallel) GC in this example with interest, but forgive me if I ask a more minor question regarding your modification of an extra parameter, "n", to "heavytask". Does this really help (to ensure that each core does work independently)? Surely, with fibs now described in a where clause, the "0:1:etc." form would not be shared among the (8) instantiations of "heavytask"? > heavytask m n = putMVar m $! (fibs !! 100000) > where > fibs = n : (n+1) : zipWith (+) fibs (tail fibs) Regards, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/d85eb477/attachment.htm From benja.fallenstein at gmail.com Tue Dec 23 14:05:37 2008 From: benja.fallenstein at gmail.com (Benja Fallenstein) Date: Tue Dec 23 13:57:56 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? In-Reply-To: <694519c50812221752q577afaf8h7793ad4c64eacf13@mail.gmail.com> References: <7ca3f0160812221529x52d9e55bt8b33a782574282b6@mail.gmail.com> <694519c50812221752q577afaf8h7793ad4c64eacf13@mail.gmail.com> Message-ID: On Tue, Dec 23, 2008 at 2:52 AM, Antoine Latter wrote: > Although I still had to use my own because I wanted a MonadPlus > instance. I would offer a patch, but since there's more than one > useful MonadPlus instance for MaybeT it probably still wouldn't be > right for everyone. Umh, there is a MonadPlus instance in the package? http://hackage.haskell.org/packages/archive/MaybeT/0.1.2/doc/html/Control-Monad-Maybe.html (It's the one based on the Maybes.) - Benja From benja.fallenstein at gmail.com Tue Dec 23 14:08:00 2008 From: benja.fallenstein at gmail.com (Benja Fallenstein) Date: Tue Dec 23 14:00:20 2008 Subject: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library? In-Reply-To: References: <7ca3f0160812221529x52d9e55bt8b33a782574282b6@mail.gmail.com> <694519c50812221752q577afaf8h7793ad4c64eacf13@mail.gmail.com> Message-ID: On Tue, Dec 23, 2008 at 8:05 PM, Benja Fallenstein wrote: > Umh, there is a MonadPlus instance in the package? Ah: ...in the version Cale uploaded two days ago, not in the previous version. Sorrynevermindisee :) - Benja From lists at qseep.net Tue Dec 23 14:21:41 2008 From: lists at qseep.net (Lyle Kopnicky) Date: Tue Dec 23 14:14:00 2008 Subject: [Haskell-cafe] How does one use Text.Regex.Base.RegexLike? Message-ID: <670e468e0812231121y4bef311ajefd2a43cbd3db32@mail.gmail.com> I'm trying to migrate code from using the old Text.Regex to the new Text.Regex.Base. But, I'm getting type errors. I can't even create a regex. Looking at the docs, it seems like this should print "bcd": import Data.Array import Text.Regex.Base import Text.Regex.Posix rx = makeRegex "a(.*)A" Just (_, mt, _) = matchOnceText rx "abcdA" main = putStrLn (fst (mt ! 0)) But I get an error: src\regex.hs:5:5: No instance for (RegexMaker regex compOpt execOpt [Char]) arising from a use of `makeRegex' at src\regex.hs:5:5-22 Possible fix: add an instance declaration for (RegexMaker regex compOpt execOpt [Char]) In the expression: makeRegex "a(.*)A" In the definition of `rx': rx = makeRegex "a(.*)A" src\regex.hs:7:18: No instance for (RegexLike regex [Char]) arising from a use of `matchOnceText' at src\regex.hs:7:18-41 Possible fix: add an instance declaration for (RegexLike regex [Char]) In the expression: matchOnceText rx "abcdA" In a pattern binding: Just (_, mt, _) = matchOnceText rx "abcdA" Why does it say there is no instance? Isn't the instance imported by Text.Regex.Posix? Why in the world is it so complicated just to get a matched substring out of the text? Is there an easier way? Thanks, Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/fd442bfe/attachment.htm From byorgey at seas.upenn.edu Tue Dec 23 14:28:29 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue Dec 23 14:20:46 2008 Subject: [Haskell-cafe] monad constraint + record update In-Reply-To: <494FCC0B.30308@udo.edu> References: <494FCC0B.30308@udo.edu> Message-ID: <20081223192829.GA24438@seas.upenn.edu> On Mon, Dec 22, 2008 at 06:19:07PM +0100, Peter Padawitz wrote: > I'd like to define a monad Set for types in the class Eq. But how can the > arguments of Set be constrained when Set is defined as an instance of > Monad? instance Eq a => Monad Set where ... obviously cannot work. > > Is there a standard update function for fields in data types, something > that OO programmers do with assignments like obj.attr := value ? > > Peter > Note there is already a package on Hackage to do exactly this, rmonad. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rmonad -Brent From dons at galois.com Tue Dec 23 14:29:09 2008 From: dons at galois.com (Don Stewart) Date: Tue Dec 23 14:21:20 2008 Subject: [Haskell-cafe] The Haskell re-branding exercise In-Reply-To: <44D34BB4-5732-4E29-8684-5091FD502810@lempsink.nl> References: <494EA1EE.1010606@cogito.org.uk> <3d96ac180812211319t21e7749en7737a4e9d27edfc6@mail.gmail.com> <20081221212333.GB25249@scytale.galois.com> <3d96ac180812211326s46953569wdce3c65f76abeb42@mail.gmail.com> <44D34BB4-5732-4E29-8684-5091FD502810@lempsink.nl> Message-ID: <20081223192909.GA3154@scytale.galois.com> eelco: > On 21 dec 2008, at 22:26, Sebastian Sylvan wrote: > >I am very shortly travelling abroad for several weeks and will not > >have (reliable access to) a computer, but isn't this a task for one > >of the haskell web-apps people (HSP, HAppS, Turbinado, etc.) to show > >us once and for all why *their* library is better than the > >competition? :-) > > Hmm, right. I started on a thing in HAppS. See > http://github.com/eelco/voting/ for the source code (contributors more > than welcome!) and http://code.tupil.com/voting/ for a live demo. It > relies heavily on javascript, needs some work on the UI and there are a > lot of features that could be added, but "it works". > Yay! Yes, let's do something like this. -- Don From jeremy at n-heptane.com Tue Dec 23 14:29:20 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue Dec 23 14:21:40 2008 Subject: [Haskell-cafe] How does one use Text.Regex.Base.RegexLike? In-Reply-To: <670e468e0812231121y4bef311ajefd2a43cbd3db32@mail.gmail.com> References: <670e468e0812231121y4bef311ajefd2a43cbd3db32@mail.gmail.com> Message-ID: <87d4fizo4v.wl%jeremy@n-heptane.com> Hello, Does this help? http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/ j. At Tue, 23 Dec 2008 11:21:41 -0800, Lyle Kopnicky wrote: > > [1 ] > [1.1 ] > I'm trying to migrate code from using the old Text.Regex to the new > Text.Regex.Base. But, I'm getting type errors. I can't even create a regex. > Looking at the docs, it seems like this should print "bcd": > > import Data.Array > import Text.Regex.Base > import Text.Regex.Posix > > rx = makeRegex "a(.*)A" > > Just (_, mt, _) = matchOnceText rx "abcdA" > > main = putStrLn (fst (mt ! 0)) > > > But I get an error: > > src\regex.hs:5:5: > No instance for (RegexMaker regex compOpt execOpt [Char]) > arising from a use of `makeRegex' at src\regex.hs:5:5-22 > Possible fix: > add an instance declaration for > (RegexMaker regex compOpt execOpt [Char]) > In the expression: makeRegex "a(.*)A" > In the definition of `rx': rx = makeRegex "a(.*)A" > > src\regex.hs:7:18: > No instance for (RegexLike regex [Char]) > arising from a use of `matchOnceText' at src\regex.hs:7:18-41 > Possible fix: > add an instance declaration for (RegexLike regex [Char]) > In the expression: matchOnceText rx "abcdA" > In a pattern binding: Just (_, mt, _) = matchOnceText rx "abcdA" > > Why does it say there is no instance? Isn't the instance imported by > Text.Regex.Posix? > > Why in the world is it so complicated just to get a matched substring out of > the text? Is there an easier way? > > Thanks, > Lyle > [1.2 ] > > [2 ] > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From byorgey at seas.upenn.edu Tue Dec 23 14:30:23 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue Dec 23 14:22:42 2008 Subject: [Haskell-cafe] monad constraint + record update In-Reply-To: <494FCC0B.30308@udo.edu> References: <494FCC0B.30308@udo.edu> Message-ID: <20081223193023.GB24438@seas.upenn.edu> > > Is there a standard update function for fields in data types, something > that OO programmers do with assignments like obj.attr := value ? Oh, I missed this question the first time. You probably want Functional References: http://twan.home.fmf.nl/blog/haskell/overloading-functional-references.details -Brent From dons at galois.com Tue Dec 23 14:42:23 2008 From: dons at galois.com (Don Stewart) Date: Tue Dec 23 14:34:31 2008 Subject: [Haskell-cafe] New Haskell logo contest In-Reply-To: References: Message-ID: <20081223194223.GC3154@scytale.galois.com> fruehr: > I think this logo contest is a great idea. I submitted my "classy > Haskell" logo from the merch. page, but I have to > admit I like some of the other ones on the submission page a whole lot. > > Hey, *here's* an idea: maybe whoever wins the logo contest has to take > over management of the Haskell > merchandise page on CafePress! :) > Thanks for your (nearly decade long?) involvement in the logo story, Fritz!! -- Don From ekirpichov at gmail.com Tue Dec 23 14:48:23 2008 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Dec 23 14:40:40 2008 Subject: [Haskell-cafe] monad constraint + record update In-Reply-To: <20081223193023.GB24438@seas.upenn.edu> References: <494FCC0B.30308@udo.edu> <20081223193023.GB24438@seas.upenn.edu> Message-ID: <5e0214850812231148m5771a48cg25e936d427571ae0@mail.gmail.com> I think that Conal Elliot's Semantic Editor Combinators do the thing even better: http://conal.net/blog/posts/semantic-editor-combinators/ 2008/12/23 Brent Yorgey : >> >> Is there a standard update function for fields in data types, something >> that OO programmers do with assignments like obj.attr := value ? > > Oh, I missed this question the first time. You probably want > Functional References: > > http://twan.home.fmf.nl/blog/haskell/overloading-functional-references.details > > -Brent > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- ??????? ???????? ??????????? ??????.??????? From wqeqweuqy at hotmail.com Tue Dec 23 14:53:11 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Tue Dec 23 14:45:47 2008 Subject: [Haskell-cafe] Re: concurrent haskell: thread priorities In-Reply-To: <4c44d90b0812221442p2933e84dl90c81bb2f986dd3c@mail.gmail.com> References: <4c44d90b0812221442p2933e84dl90c81bb2f986dd3c@mail.gmail.com> Message-ID: Thomas DuBuisson wrote: > It seems like we could get some priority based scheduling (and still > be slackers) if we allow marked green threads to be strictly > associated with a specific OS thread (forkChildIO?). > > > I think you want the GHC-only GHC.Conc.forkOnIO > > Suggestions like this are more motivation for the suggestion [1] to > adopt a re-engineered / haskell-based RTS [2]. > > Tom > > [1] > http://www.reddit.com/r/haskell_proposals/comments/7itaz/simple_robust_maintainable_rts_for_ghc_io_pdf/ > [2] http://www.seas.upenn.edu/~lipeng/homepage/papers/lmpjt07hw.pdf > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe GHC.Conc.forkOnIO is helpful but doest work in this case - it doesn't attach them to the same OS thread. From lists at qseep.net Tue Dec 23 15:09:48 2008 From: lists at qseep.net (Lyle Kopnicky) Date: Tue Dec 23 15:02:07 2008 Subject: [Haskell-cafe] How does one use Text.Regex.Base.RegexLike? In-Reply-To: <87d4fizo4v.wl%jeremy@n-heptane.com> References: <670e468e0812231121y4bef311ajefd2a43cbd3db32@mail.gmail.com> <87d4fizo4v.wl%jeremy@n-heptane.com> Message-ID: <670e468e0812231209l53d545dfr311bd8725fa4e8a@mail.gmail.com> Yes, sort of. It enables me to get some simple examples working with (=~). But I still don't know how to get makeRegex to work. You need it to specify options like case insensitivity, or to use functions like matchAllText. On Tue, Dec 23, 2008 at 11:29 AM, Jeremy Shaw wrote: > Hello, > > Does this help? > > > http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/ > > j. > > At Tue, 23 Dec 2008 11:21:41 -0800, > Lyle Kopnicky wrote: > > > > [1 ] > > [1.1 ] > > I'm trying to migrate code from using the old Text.Regex to the new > > Text.Regex.Base. But, I'm getting type errors. I can't even create a > regex. > > Looking at the docs, it seems like this should print "bcd": > > > > import Data.Array > > import Text.Regex.Base > > import Text.Regex.Posix > > > > rx = makeRegex "a(.*)A" > > > > Just (_, mt, _) = matchOnceText rx "abcdA" > > > > main = putStrLn (fst (mt ! 0)) > > > > > > But I get an error: > > > > src\regex.hs:5:5: > > No instance for (RegexMaker regex compOpt execOpt [Char]) > > arising from a use of `makeRegex' at src\regex.hs:5:5-22 > > Possible fix: > > add an instance declaration for > > (RegexMaker regex compOpt execOpt [Char]) > > In the expression: makeRegex "a(.*)A" > > In the definition of `rx': rx = makeRegex "a(.*)A" > > > > src\regex.hs:7:18: > > No instance for (RegexLike regex [Char]) > > arising from a use of `matchOnceText' at src\regex.hs:7:18-41 > > Possible fix: > > add an instance declaration for (RegexLike regex [Char]) > > In the expression: matchOnceText rx "abcdA" > > In a pattern binding: Just (_, mt, _) = matchOnceText rx "abcdA" > > > > Why does it say there is no instance? Isn't the instance imported by > > Text.Regex.Posix? > > > > Why in the world is it so complicated just to get a matched substring out > of > > the text? Is there an easier way? > > > > Thanks, > > Lyle > > [1.2 ] > > > > [2 ] > > _______________________________________________ > > 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/20081223/a6d1ebbb/attachment.htm From daniel.is.fischer at web.de Tue Dec 23 15:30:13 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Dec 23 15:20:07 2008 Subject: [Haskell-cafe] How does one use Text.Regex.Base.RegexLike? In-Reply-To: <670e468e0812231209l53d545dfr311bd8725fa4e8a@mail.gmail.com> References: <670e468e0812231121y4bef311ajefd2a43cbd3db32@mail.gmail.com> <87d4fizo4v.wl%jeremy@n-heptane.com> <670e468e0812231209l53d545dfr311bd8725fa4e8a@mail.gmail.com> Message-ID: <200812232130.13146.daniel.is.fischer@web.de> Am Dienstag, 23. Dezember 2008 21:09 schrieb Lyle Kopnicky: > Yes, sort of. It enables me to get some simple examples working with (=~). > But I still don't know how to get makeRegex to work. You need it to specify > options like case insensitivity, or to use functions like matchAllText. > Your problem is that GHC can't know which instance to choose. You can help it by giving a type signature, e.g. rx :: Regex rx = makeRegex "a(.*)A" HTH, Daniel > > At Tue, 23 Dec 2008 11:21:41 -0800, > > > > Lyle Kopnicky wrote: > > > I'm trying to migrate code from using the old Text.Regex to the new > > > Text.Regex.Base. But, I'm getting type errors. I can't even create a > > > > regex. > > > > > Looking at the docs, it seems like this should print "bcd": > > > > > > import Data.Array > > > import Text.Regex.Base > > > import Text.Regex.Posix > > > > > > rx = makeRegex "a(.*)A" > > > > > > Just (_, mt, _) = matchOnceText rx "abcdA" > > > > > > main = putStrLn (fst (mt ! 0)) > > > > > > > > > But I get an error: > > > > > > src\regex.hs:5:5: > > > No instance for (RegexMaker regex compOpt execOpt [Char]) > > > arising from a use of `makeRegex' at src\regex.hs:5:5-22 > > > Possible fix: > > > add an instance declaration for > > > (RegexMaker regex compOpt execOpt [Char]) > > > In the expression: makeRegex "a(.*)A" > > > In the definition of `rx': rx = makeRegex "a(.*)A" > > > > > > src\regex.hs:7:18: > > > No instance for (RegexLike regex [Char]) > > > arising from a use of `matchOnceText' at src\regex.hs:7:18-41 > > > Possible fix: > > > add an instance declaration for (RegexLike regex [Char]) > > > In the expression: matchOnceText rx "abcdA" > > > In a pattern binding: Just (_, mt, _) = matchOnceText rx "abcdA" > > > > > > Why does it say there is no instance? Isn't the instance imported by > > > Text.Regex.Posix? > > > > > > Why in the world is it so complicated just to get a matched substring > > > out > > > > of > > > > > the text? Is there an easier way? > > > > > > Thanks, > > > Lyle > > > [1.2 ] > > > > > > [2 ] > > > _______________________________________________ > > > Haskell-Cafe mailing list > > > Haskell-Cafe@haskell.org > > > http://www.haskell.org/mailman/listinfo/haskell-cafe From lists at qseep.net Tue Dec 23 15:30:33 2008 From: lists at qseep.net (Lyle Kopnicky) Date: Tue Dec 23 15:22:51 2008 Subject: [Haskell-cafe] How does one use Text.Regex.Base.RegexLike? In-Reply-To: <200812232130.13146.daniel.is.fischer@web.de> References: <670e468e0812231121y4bef311ajefd2a43cbd3db32@mail.gmail.com> <87d4fizo4v.wl%jeremy@n-heptane.com> <670e468e0812231209l53d545dfr311bd8725fa4e8a@mail.gmail.com> <200812232130.13146.daniel.is.fischer@web.de> Message-ID: <670e468e0812231230l5a080115lbe6845438faa0659@mail.gmail.com> Yes, that worked, thanks. I just figured that out too. Here's a whole working program: import Text.Regex.Base import Text.Regex.Posix rx :: Regex rx = makeRegex "a(.*)A" mr = match rx "abcdA" text = head $ mrSubList mr main = putStrLn text On Tue, Dec 23, 2008 at 12:30 PM, Daniel Fischer wrote: > Am Dienstag, 23. Dezember 2008 21:09 schrieb Lyle Kopnicky: > > Yes, sort of. It enables me to get some simple examples working with > (=~). > > But I still don't know how to get makeRegex to work. You need it to > specify > > options like case insensitivity, or to use functions like matchAllText. > > > > Your problem is that GHC can't know which instance to choose. You can help > it > by giving a type signature, e.g. > > rx :: Regex > rx = makeRegex "a(.*)A" > > HTH, > Daniel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/c2cf5211/attachment.htm From cetin.sert at gmail.com Tue Dec 23 15:31:38 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Tue Dec 23 15:24:03 2008 Subject: [Haskell-cafe] hackage, gtk2hs Message-ID: <1ff5dedc0812231231m450b7de5r66ef9c1330ab48d1@mail.gmail.com> Hi, A package I want to upload only builds with the unreleased gtk2hs version from the darcs repository and not the latest released version 0.9.13 or any lesser. But the repository version seems to not have changed, so if I say in my cabal file: gtk >= 0.9.14 it does not even build with the gtk2hs version from the repos, on the other hand if I say: gtk >= 0.9.13 people using 0.9.13 may be surprised to see the package does not build. What should I do o__O? Wait for the next gtk2hs release before releasing my package? Or is there a way to notify _potential users/those interested_ of the need to use the latest gtk2hs they can get from the darcs repos. Best Regards, Cetin Sert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/8bef5e3d/attachment.htm From schlepptop at henning-thielemann.de Tue Dec 23 16:02:34 2008 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Tue Dec 23 15:49:39 2008 Subject: [Haskell-cafe] understanding enumerator/iteratee In-Reply-To: <42784f260812220518t5114a6f1nef7e178a9813fc34@mail.gmail.com> References: <42784f260812200111y320fafd4ja8d8bb1a52573808@mail.gmail.com> <2076f2f90812202135o6db3a3b0t2971d5f8ca6cb39f@mail.gmail.com> <42784f260812220258lb10e0dfpaee853a9989fa451@mail.gmail.com> <2076f2f90812220317q47e84d1fr37a5d0f863b8c684@mail.gmail.com> <42784f260812220518t5114a6f1nef7e178a9813fc34@mail.gmail.com> Message-ID: <495151EA.5090906@henning-thielemann.de> Jason Dusek schrieb: > I'm taking a stab at composable