Re: [Haskell-cafe] Unicode case (in)stability and Haskell identifiers.
I try to maintain some knowledge of Unicode issues, but this one never occurred to me. On Fri, Nov 2, 2012 at 10:28 AM, Richard O'Keefe o...@cs.otago.ac.nz wrote: Would anyone care to see and comment on the proposal before I send it to Unicode.org? Anyone got any suggestions before I begin to write it? I don't have any suggestions, but I would certainly be interested in seeing your proposal. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC rendering of non-ASCII characters configurable?
On Sun, Jul 29, 2012 at 8:04 PM, Richard Cobbe co...@ccs.neu.edu wrote: This is annoying because all of the Unicode charts give the code points in hex, and indeed the charts are split into different PDFs at numbers that are nice and round in hex but not in decimal. So in order to figure out which character I'm looking at, I have to convert back to hex and then look it up in the charts. My reading of the Haskell 98 report is that the Show instance for Char *could* use hex escapes, so this is a compiler choice. If there isn't a good reason for this choice, perhaps GHC could change? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question on proper use of Data.IORef
On Fri, Jun 22, 2012 at 5:30 PM, Captain Freako capn.fre...@gmail.com wrote: 12 main = do 13 let theValue = 1 14 print theValue 15 theValueRef - newIORef theValue 16 bump theValueRef 17 return theValue theValue is a plain old immutable Haskell variable. newIORef creates an IORef whose initial value is equal to the argument; it doesn't create a pointer to the value or something like that. Change return theValue to readIORef theValueRef to extract the changed value in the IORef. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is protocol-buffers package maintainer reachable?
On Mon, Apr 23, 2012 at 15:01, Paul Graphov grap...@gmail.com wrote: And what should I do if he is unreachable? My feeling is that if you are willing to take it on, you should ask this list if anybody objects to your taking over the maintainership, and if they do not, take it over (on Hackage, this just means uploading a new version of the package). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] graphviz: dotizeGraph and graphToGraph not adding positions
My understanding of the documentation for Data.GraphViz.dotizeGraph and graphToGraph is that they should add position attributes to a graph. But they always seem to return graphs with empty attribute lists. What am I doing wrong in the following tiny example? dotizeGraph nonClusteredParams (insNode (0, Blah) $ empty :: Gr String ()) 0:([],Blah)-[] I expected the first list to contain at least a Pos attribute. I have written a wrapper around /usr/share/dot which shows the program is outputting positional information. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Package documentation complaints -- and a suggestion
On Tue, Oct 25, 2011 at 11:17, Ketil Malde ke...@malde.org wrote: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes: Right, but first we need to define what all those terms _mean_... and it's no good saying your package is stable if you change the API in a large-scale fashion every release. I think there are better criteria to use, like: - do exported definition have Haddock comments? - does the package have an automated test suite? - is the package used by other packages? - ...by different authors? - has the package been recently updated? This is useful information, but to call it stability is not only misleading, but it also prevents the package from using that field to indicate whether or not it is stable! --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: vector-bytestring-0.0.0.0
On Fri, Oct 14, 2011 at 13:45, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Though I would argue that unless you're trying to actually use for Show/Read for serialisation, does it really matter what the Show/Read instances for Bytestring are? Convenient debugging and REPL interaction certainly matter! --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Package documentation complaints -- and a suggestion
On Mon, Oct 10, 2011 at 03:17, John Millikin jmilli...@gmail.com wrote: The package summary is Type-safe ADT-database mapping library., which gives some idea about what it does. Whence my suggestion to show this on the package's page. Perhaps I shouldn't have hidden that at the bottom -- I meant this as my main point, and I'm afraid I got a little side-tracked. In my experience, any package that starts its source files with {-# LANGUAGE GADTs, TypeFamilies, ExistentialQuantification, StandaloneDeriving, TypeSynonymInstances, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, FlexibleContexts, OverlappingInstances, ScopedTypeVariables, GeneralizedNewtypeDeriving, UndecidableInstances, EmptyDataDecls #-} is probably an experiment in what is possible, rather than a production-friendly library. An experiment that I was interested in, and hoped to find out more about. But anyway, I see your point. Many people upload experimental packages to Hackage so that they can be used by other interested people, even though the packages are not ready/intended for mass consumption. A lack of documentation in such cases is understandable. Some way of documenting this fact would, however, be helpful. I wonder if it would be worth giving package uploaders control over whether their packages are shown on the package list? Packages can be manually hidden by emailing an admin, but that's a lot of trouble. In this case I followed an external link, so that would not have helped me. There is the stability field, which has an experimental value, but it's not at all clear what the different values mean other than stable. It is fair that some packages on Hackage are not intended for human consumption. Perhaps this is caused in part by having our package installer and humans looking in the same place for information about Haskell libraries. But I think we can do a better job of distinguishing these packages. Perhaps a visibility or release-status field? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Package documentation complaints -- and a suggestion
On Mon, Oct 10, 2011 at 10:06, Paterson, Ross r.pater...@city.ac.uk wrote: Max Rabkin writes: But I also have a concrete suggestion for Hackage: include the package synopsis on the package's page. The distinction between synopsis and description can be confusing, and sometimes it seems to violate DRY to have the same info in both. You may have missed the header on the package page (dark line at the top). I did indeed. Perhaps it should be bigger? I've just opened up Synaptic, and it is indeed separate from the description, but there the synopsis is used as a heading for the description, and it's the biggest thing on the screen (whereas Hackage uses package name). The distinction between synopsis and description is borrowed from the Debian package format: http://www.debian.org/doc/debian-policy/ch-binary.html#s-descriptions The two fields are aimed at different audiences. A Synopsis trying to do double duty as the beginning of a general package description won't work as well as a stand-alone summary for package lists, etc. Good point. On the other hand, nobody points package authors to the Debian documentation (and Debian also has review for newly uploaded packages, as far as I know). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Package documentation complaints -- and a suggestion
Hi all Following a link from the Yesod book, I arrived at [1], curious to find out what groundhog was. Once there, I learned... nothing: This library provides just the general interface and helper functions. You must use a specific backend in order to make this useful. [1] http://hackage.haskell.org/package/groundhog Hoping to find more, I clicked on the top-level module. Once again, the text here was uninformative, though from the example it seems to be something to do with databases (and it is to be applauded for including an example in the docs). So, package authors: PLEASE, tell me what your package does in the description. Tell me *again* in the top-level haddocks (I may have come directly there by a link). And then, tell me where to look for more information. Instead of This module defines the functions and datatypes used throughout the framework. Most of them are for internal use, tell me which are *not* for internal use. Write documentation for people who don't know how to use your package. Some people prefer to have this outside of the haddocks (I don't like this because papers and blogs are less likely to stay up to date than what is embedded in the file, but for tutorials etc. a website might be more appropriate) but if so link to it from both the Haddocks and the package description. But I also have a concrete suggestion for Hackage: include the package synopsis on the package's page. The distinction between synopsis and description can be confusing, and sometimes it seems to violate DRY to have the same info in both. To the author of groundhog: I hope you are not offended by my picking on your package. It's not the only culprit -- just the one that pushed me over the edge. Of course, I would be pleased if this email encouraged you to fix it, but I am addressing this rant to the Haskell community because the problem is a cultural one. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Converting wiki pages into pdf
This doesn't answer your Haskell question, but Wikpedia has PDF-generation facilities (Books). Take a look at http://en.wikipedia.org/wiki/Help:Book (for single articles, just use the download PDF option in the sidebar). --Max On Thu, Sep 8, 2011 at 14:34, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote: Hello all I am trying to write a Haskell program which download html pages from wikipedia including images and convert them into pdf . I wrote a small script import Network.HTTP import Data.Maybe import Data.List main = do x - getLine htmlpage - getResponseBody = simpleHTTP ( getRequest x ) -- open url --print.words $ htmlpage let ind_1 = fromJust . ( \n - findIndex ( n `isPrefixOf`) . tails $ htmlpage ) $ !-- content -- ind_2 = fromJust . ( \n - findIndex ( n `isPrefixOf`) . tails $ htmlpage ) $ !-- /content -- tmphtml = drop ind_1 $ take ind_2 htmlpage writeFile down.html tmphtml and its working fine except some symbols are not rendering as it should be. Could some one please suggest me how to accomplish this task. Thank you Mukesh Tiwari ___ 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
Re: [Haskell-cafe] Fixed points
On Fri, Jun 10, 2011 at 21:05, Alexander Solla alex.so...@gmail.com wrote: equivalenceClosure :: (Ord a) = Relation a - Relation a equivalenceClosure = fix (\f - reflexivity . symmetry . transitivity) If you want to learn about fix, this won't help you, but if you're just want the best way to calculate equivalence closures of relations, then it's probably equivalenceClosure = transitivity . symmetry . reflexivity assuming those are the transitive, symmetric and reflexive closure functions. You still need some kind of iteration to get the transitive closure. The algorithm I know of for that is Warshall's Algorithm, which is O(N^3) (possibly with a log N factor for pure data structures). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: dtd-text DTD parser, V0.1.0.0
On Sun, Jun 5, 2011 at 19:13, Yitzchak Gale g...@sefer.org wrote: I really should have edited the Cabal description of this package before I uploaded it. It promises an attoparsec-text parser and blaze-builder renderer for DTDs. First of all, the renderer is vaporware - I haven't written it yet. Just the parser was quite a bit of work, so I decided to release it before even starting on the renderer. Could you upload a bugfix version with an accurate description? This could be very frustrating to a random hackage-brower who hasn't read the announcement (or me, in a few months, having forgotten this announcement). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Comment Syntax
On Fri, Jun 3, 2011 at 10:32, Guy guytsalmave...@yahoo.com wrote: -- followed by a symbol does not start a comment, thus for example, haddock declarations must begin with -- |, and not --|. What might --| mean, if not a comment? It doesn't seem possible to define it as an operator. GHCi, at least, allows it. Prelude let (--|) = (+) Prelude 1 --| 2 3 --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Apache license, any drawbacks for Haskell packages?
On Mon, May 9, 2011 at 10:59, Jason Dagit dag...@gmail.com wrote: On Sun, May 8, 2011 at 1:25 PM, Magnus Therning mag...@therning.org wrote: Are there any drawbacks to using the Apache license for Haskell packages? I don't think so. It looks to be almost identical to using BSD3, which is already quite popular for haskellers. I would consider this, in itself, to be a small but significant disadvantage. Anyone who uses Haskell is going to know (and probably be comfortable with) the BSD3 license. If I find Apache-licensed code, I now have to look that up, determine the differences between it and BSD3, find out whether it's compatible with the GPL and BSD3. Basically, the cost of introducing *any* new license to a software ecosystem is non-zero. Of course, a widespread license like Apache is better than making up your own. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to use cabal's data-files feature and run in-place?
On Fri, Apr 22, 2011 at 03:46, Richard Cobbe co...@ccs.neu.edu wrote: Unfortunately, that's not happening. Cabal is clearly generating the module; I can see it in dist/build/autogen. But my copy is overriding the autogenerated one, even for cabal builds -- at least, that's what I'm seeing when I run the binary out of dist/build/package/executable. I'm no Cabal expert, but the first thing I'd try is to leave your copy out of the list of included files in the Cabal file. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Encoding of Haskell source files
2011/4/4 Ketil Malde ke...@malde.org: I think the safest thing to do is to require source to be ASCII, and provide escapes for code points 127... I used to think that until I realised it meant having -- Author: Ma\xef N\xe5me In code, single characters aren't bad (does Haskell have something like Python's named escapes (\N{small letter a with ring}?) but reading UI strings is less fun. Also, unicode symbols for - and the like are becoming more popular. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learn You a Haskell for Great Good - a few doubts
On Fri, Mar 4, 2011 at 17:37, Chris Smith cdsm...@gmail.com wrote: The most common use of Ord in real code, to be honest, is to use the value in some data structure like Data.Set.Set or Data.Map.Map, which requires Ord instances. For this purpose, any Ord instance that is compatible with Eq will do fine. It's true that you can build valid Maps and Sets with any valid instance of Ord that defines a total order that is consistent with Eq, and lookup, membership testing and insert will work. However, there are operations on Maps and Sets which make the order visible to the caller: min, max, splits, folds, etc. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why is there no splitSeperator function in Data.List
On Mon, Feb 14, 2011 at 07:52, Evan Laforge qdun...@gmail.com wrote: the simple 'join :: String - [String] - String' and 'split :: String - String - [String]' versions work in enough cases. BTW, this join is Data.List.intercalate. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANN: case-insensitive-0.1
Hi Bas This could be a useful package but can you add a note that this does not do correct Unicode-aware comparison on String (though AFAICT it is correct for Text)? --Max On Mon, Feb 7, 2011 at 02:06, Bas van Dijk v.dijk@gmail.com wrote: Dear all, I had this old module laying around that I wrote some time ago. I dusted it off and uploaded it to Hackage: http://hackage.haskell.org/package/case-insensitive-0.1 The package provides the module Data.CaseInsensitive which exports the CI type constructor which can be parameterised by a string-like type like: String, ByteString, Text, etc.. Comparisons of values of the resulting type are then insensitive to cases. It is my hope that one day packages like snap-core[1], http-types[2] or wai[3] all use this common way of making strings case insensitive. Regards, Bas [1] http://hackage.haskell.org/packages/archive/snap-core/latest/doc/html/Data-CIByteString.html [2] http://hackage.haskell.org/packages/archive/http-types/0.3.0/doc/html/Network-HTTP-Types.html#t:CIByteString [3] http://hackage.haskell.org/packages/archive/wai/latest/doc/html/Network-Wai.html#v:CIByteString ___ Haskell mailing list hask...@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Tool for evaluating GHCi lines in a source file
On Sun, Jan 23, 2011 at 12:35, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: Hi, some time ago I read of a small tool that extracts lines like GHCi some_expression from a source file and appends GHCi's output to them. Now I can't find it again. Does anyone remember its name? No, but I can guess (it's the same as the Python original, modulo capitalisation): http://hackage.haskell.org/package/DocTest ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polymorphic function over pairs of maybes.
On Tue, Dec 28, 2010 at 21:23, Edward Amsden eca7...@cs.rit.edu wrote: (Int, (String, (Int, Int))) and another where each individual value is a Maybe of the corresponding type, for example: (Maybe Int, (Maybe String, (Maybe Int, Maybe Int))) This example demonstrates exactly why you might want to avoid doing this... if you apply Maybe as deeply inside type constructors as possible, you actually get (Maybe Int, ([Maybe Char], (Maybe Int, Maybe Int))) and in general you may not know or care whether a type is atomic or not. There may be a way which works if you specify the target type as well. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] intent-typing
I still don't understand what intent typing is, but this particular problem is discussed (with a type-based, statically checked solution) at http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem --Max On Mon, Nov 15, 2010 at 17:17, Marcus Sundman sund...@iki.fi wrote: Hi, how would one go about implementing (or using if it's supported out-of-the-box) intent-typing* for haskell? *) Intent-typing is compiler/verifier/parser enforced typing similar to apps hungarian notation. E.g., say I have a webapp with fields for a user's first name and last name, which I at some point show on another webpage that the user loads, which is a typical XSS vulnerability situation. So I have 2 functions, getParam(...) and setParam(...), which return the value of a user-provided parameter and gives a parameter to the template displayed to the user, respectively. I want to somehow flag the getParam(...)-function as returning a user-provided string (say, unsafe-string), and the setParam(...)-function as requiring a safely encoded string (say, safe-string), so that if I sometimes forget to run the user-provided string through some anti-xss-encoding thingy (which would take an unsafe-string and return a safe-string), and don't (unit-)test this particular aspect of said code, then some verifier thingy (preferably a static verifier) would notice this and show me a warning. Cheers, Marcus ___ Haskell mailing list hask...@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Serialization of (a - b) and IO a
On Thu, Nov 11, 2010 at 11:25, Bob tom.da...@gmail.com wrote: I don't think I agree, I didn't see a rule f == g = serialise f == serialise g anywhere. The rule a == b = f a == f b is called referential transparency (for denotational equality, not Eq) and is (perhaps the most important) part of what is meant by purely functional. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Weekly News: Issue 155 - October 20, 2010
On Thu, Oct 21, 2010 at 11:38, Ketil Malde ke...@malde.org wrote: Are there actually people subscribed to -cafe, but *not* to hask...@? Yes. And if so, why? Because... I'm always getting two copies of everything in haskell@, since everything is cross-posted to -cafe. :) --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On Mon, Oct 11, 2010 at 00:51, Ozgur Akgun ozgurak...@gmail.com wrote: My point was: you need to find/define two operators, not just one. That still holds :) No it doesn't. f $ g $ h $ x == f (g (h x)) == f . g . h $ x == x $$ h $$ g $$ f if you have the correct associativity for ($$) --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Coding conventions for Haskell?
On Mon, Sep 27, 2010 at 22:57, Andrew Coppin andrewcop...@btinternet.com wrote: data Foo a b = Foo a | Bar b | Foobar a b deriving (Eq, Ord) It honestly annoys me that Haddock disagrees with me on this point... I disagree with you too, and so does your version control (if I'm wrong, please tell me, so I can switch). If you add a constructor, you have to make a change to the line containing the old last constructor, even though you didn't actually change that line. Also, either your pipes don't line up, or you violate your own rule I generally try to structure my code so that all blocks indent by 2 spaces, and the size of indentation never depends on the length of an identifier. ...except that the spaces here are not indentation. --Max (exhausted from real work, so taking some time out to paint the bikeshed) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Higher-order algorithms
(Accidentally sent off-list, resending) On Mon, Aug 23, 2010 at 15:03, Eugene Kirpichov ekirpic...@gmail.com wrote: * Difference lists I mean that not only higher-order facilities are used, but the essence of the algorithm is some non-trivial higher-order manipulation. If I'm not mistaken, we can defunctionalize difference lists like this: data DList a = Chunk [a] | Concat (DList a) (DList a) fromList = Chunk () = Concat singleton = Chunk . (:[]) empty = Chunk [] toList dl = dl `fold` [] where infixr `fold` fold :: DList a - [a] - [a] fold (Concat l r) ys = l `fold` r `fold` ys fold (Chunk xs) ys = xs ++ ys (This implementation has only been lightly tested) And of course, we knew this was possible, since we can compile DLists to first-order machines. I agree that the functional, higher-order presentation is clear and elegant. But is it essential? Also, I'm curious about how this performs relative to the functional version. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Maybe to Either -- is there a better way?
On Tue, Aug 3, 2010 at 8:33 PM, Claude Heiland-Allen claudiusmaxi...@goto10.org wrote: {-# LANGUAGE TemplateHaskell, ScopedTypeVariables #-} import Language.Haskell.Djinn (djinnD) $(djinnD maybeToEither [t|forall a b . a - Maybe b - Either a b|]) main = print . map (maybeToEither foo) $ [Nothing, Just bar] This is very cool (as is Djinn itself), but for me the ideal syntax would be maybeToEither :: a - Maybe b - Either a b maybeToEither = $(derived) Is something like this possible in TH? The splice would have to know its declared (even inferred?) type. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is 'flip' really necessary?
On Mon, Jul 26, 2010 at 10:42 PM, Nils m...@n-sch.de wrote: On 26.07.2010 08:33, David Virebayre wrote: listeEtagTot = concatMap (`listeEtagArm` cfgTypesTringle) listeArmOrd You can use flip as a wildcard aswell: listeEtagTot = concatMap (listeEtagArm `flip` cfgTypesTringle) listeArmOrd Makes it even more readable in my opinion, since this really shows you where the value belongs to. It took me a fair while (I'm talking on the order of half a minute) to figure out what that meant, but it's pretty cool. Maybe a different name would be better? How about (??) or it? listeEtagTot = concatMap (listeEtagArm ?? cfgTypesTringle) listeArmOrd listeEtagTot = concatMap (listeEtagArm `it` cfgTypesTringle) listeArmOrd --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Random this! ;-)
On Sun, Jul 25, 2010 at 5:39 PM, michael rice nowg...@yahoo.com wrote: I know, ugly, but at least I got it to work. What's a better way to generate this list? rollNDiceIO n = sequence . replicate n $ randomRIO (1,6) {{ sequence . replicate n = replicateM n }} = replicateM n $ randomRIO (1, 6) --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Heavy lift-ing
On Sat, Jul 24, 2010 at 4:08 PM, aditya siram aditya.si...@gmail.com wrote: I wouldn't-it was a bad example. My only point was that because of the way (=) is implemented for lists the order of the arguments 'a' and 'b' in 'liftM2 f a b' matters. -deech No, it's not. The type of liftM2 makes this clear: liftM2 :: (Monad m) = (a - b - r) - m a - m b - m r The arguments to the function *must* come in the right order, because there is no way to match (a) with (m b) or (b) with (m a). Since liftM2 is parametrically polymorphic in (a) and (b), it can't behave differently in the case where (a = b). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A question about State Monad and Monad in general
On Mon, Jul 19, 2010 at 10:17 AM, Ketil Malde ke...@malde.org wrote: At it's heart, monads are just syntactic convenience, but like many other syntactic conveniences, allows you to structure your code better. Thus it's more about programmer efficiency than program efficiency. (The do notation is syntactic sugar for = and ). Well, in a sense yes, but there's more to it than do notation -- that's just syntactic sugar. The real power is like any typeclass: algorithms (in this case sequenceM, forever, liftM, etc.) that work on all monads without having to write code for each instance. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Design for 2010.2.x series Haskell Platform site
On Sat, Jul 17, 2010 at 1:43 AM, Don Stewart d...@galois.com wrote: Here's a first cut in the repo with the new design converted to CSS http://code.haskell.org/haskell-platform/download-website/ If anyone would like to clean it up further, please send me patches to the style.css file or index.html. If the background is going to tile, it should be tileable. Other options are to have only a single image, centered; or, split the images into a left and right part, place those separately, and use a stretchable background in the center. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] whine and solution about programmers not respecting documentations
On Tue, Jun 29, 2010 at 11:46 AM, Ketil Malde ke...@malde.org wrote: deleteBy :: (a - Bool) - [a] - [a] I don't think there would be any doubt what 'deleteBy (= 5) [1..10]' would do. And I just don't see what the requirement for an equivalence relation buys you. Your deleteBy is (filter . not), isn't it? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Huffman Codes in Haskell
On Tue, Jun 22, 2010 at 10:18 PM, Andrew Coppin andrewcop...@btinternet.com wrote: Don Stewart wrote: http://hackage.haskell.org/package/huffman A simple and pure Haskell implementation of the Huffman encoding algorithm. What the...? Oh, I see. It uses another package to handle the tricky sorting and searching stuff. Well, yeah, that would make the code a bit shorter... ;-) Quicksort is naturally expressed using filter and (++), etc. Huffman coding is naturally expressed in terms of priority queues, etc. Why is using the right vocabulary OK in one case and not in the other? This seems like an example of list-chauvinism -- what Chris Okasaki calls a communal blind spot of the FP community in Breadth-First Numbering: Lessons from a Small Exercise in Algorithm Design -- http://www.eecs.usma.edu/webs/people/okasaki/icfp00.ps --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] name of this monadic combinator?
On Sun, May 30, 2010 at 8:15 PM, Mike Dillon m...@embody.org wrote: That second search also shows zipWith in there; I never really thought about zipWith being like liftM2 for the list Monad. I don't believe that's actually true for the normal list Monad, but it should be true of an alternate list Monad along the lines of the Functor and Applicative instances for the ZipList newtype in Control.Applicative. ZipList does not form a monad. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Google Summer of Code: BlazeHTML RFC
On Thu, May 27, 2010 at 2:44 PM, Pierre-Etienne Meunier pierreetienne.meun...@gmail.com wrote: ** Advertisement ** Have you tried the library I have written, Data.Rope ? ** End of advertisement ** The algorithmic complexity of most operations on ropes is way better than on bytestrings : log n for all operations, except traversals, of course. Cheers, PE How is a Data.Rope.Rope different from a Data.Sequence.Seq Char? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: gt-tools-0.1.4
On Fri, May 7, 2010 at 4:12 AM, Felipe Lessa felipe.le...@gmail.com wrote: On Thu, May 06, 2010 at 09:30:50PM +0300, Sergei Trofimovich wrote: /me wonders if Miss lambdabot might like to have such functionality. What do you think? Do the terms of use of Google Translate allow it? I can't remember, but they try to block it. However, there is a public API. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re: instance Eq (a - b)
On Wed, Apr 21, 2010 at 1:44 AM, Edward Kmett ekm...@gmail.com wrote: Eq doesn't state anywhere that the instances should be structural, though in general where possible it is a good idea, since you don't have to worry about whether or not functions respect your choice of setoid. Wikipedia's definition of structural equality is an object-oriented one, but if by structural equality you mean the natural equality on algebraic datatypes (as derived automatically), I don't believe this is quite the case. If the type is abstract, surely the Eq instance need only be a quotient w.r.t. the operations defined on it. Thus, for example, two Sets can be considered equal if they contain the same elements, rather than having identical tree shapes (except that Data.Set exports unsafe functions, like mapMonotonic which has an unchecked precondition). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Garbage collecting pointers
On Fri, Mar 26, 2010 at 11:21 PM, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: On Mar 26, 2010, at 16:28 , Mads Lindstrøm wrote: For some time I have been thinking about an idea, which could limit Haskell's memory footprint. I don't know if the idea is crazy or clever, This is called pointer tagging. The original STG design avoided it because of the perceived performance loss in removing the tags before using the pointer, but as I understand it the current GHC design uses limited tagging. I'd say it's really CDR coding -- http://en.wikipedia.org/wiki/CDR_coding -- pointer tagging is just a part of it. [Sorry, Brandon, my reply all button seems elusive these days] --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Syntax programming with lexemes rather than trees?
[Sorry for the accidental off-list reply, Neil] On Tue, Mar 23, 2010 at 10:43 PM, Neil Mitchell ndmitch...@gmail.com wrote: It actually sounds like your representation has structure, but you dislike structure because it's hard to work with. It seems to me like the data has structure, but that data is not treelike! Is a performance a collection of measures or a collection of instruments? A tree-like structure makes you choose, but in truth it is both. I'm not sure I've seen a good solution to this kind of problem in FP. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] First time haskell - parse error!
On Wed, Mar 10, 2010 at 3:53 PM, Stephen Tetley stephen.tet...@gmail.com wrote: where odds = iterate (+2) 1 Or odds = [1,3..] --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Computing sums
On Sat, Feb 20, 2010 at 9:10 PM, Andrew Coppin andrewcop...@btinternet.com wrote: PS. Epic, epic comment spam. Yeah, sorry. Every now and again I decide I should deal with it. Then I rediscover that it takes about four clicks to delete each comment. Basically, I leave my blog alone until I have something (hopefully) interesting to write. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Virus alert while installing happstack
On Mon, Feb 15, 2010 at 11:28 AM, Marc Weber marco-owe...@gmx.de wrote: unlikely. If you're in doubt you should compile from source and also check the source which was used to compile ghc .. etc. I want to say if you really want to be secure the amount of work is infinity. http://cm.bell-labs.com/who/ken/trust.html --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Collection of sets containing no sets which are a subset of another in the collection
On Sat, Nov 14, 2009 at 9:21 AM, Mark Wassell mwass...@bigpond.net.au wrote: Hi, I am looking for a data structure that will represent a collection of sets such that no element in the collection is a subset of another set. In other words, inserting an element that is already a subset of another element will return the original collection, and inserting an element that is a superset of any elements will result in a collection with the superset added and the subsets removed. I *think* what you're describing is a Union-Find structure. A functional union-find structure is described in http://www.lri.fr/~filliatr/ftp/publis/puf-wml07.ps (the language used is OCaml, but if you have any difficulty translating it to Haskell I'm sure this list will offer its help). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Writing great documentation
Haskellers, I have heard many complaints about the average quality on documentation. Therefore, I'd like to encourage you all to read Jacob Kaplan-Moss's series on writing great documentation: http://jacobian.org/writing/great-documentation/. The articles are themselves well-written and contain excellent advice (though I disagree somewhat with the comments on automatically-generated documentation: I find many libraries are excellently haddocumented). Jacob Kaplan-Moss is a developer on the Django project, which is well known for the quality of its documentation. One issue he brings up is having different types of documentation. My impression of many Haskell libraries (my own included) is that, while they may have good reference documentation, they lack tutorials and topic guides. Perhaps we could bring up some examples of Haskell projects with particularly good documentation, as examples to look up to. XMonad has very good overviews and guides for developers, and I like how each user-facing xmonad-contrib module gives a small snippet showing how to use it in ones own config. One area where I think it could be improved (and I plan to do some work on this when I have more free time) is in topical guides on things like how to write your own layout. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Writing great documentation
On Fri, Nov 13, 2009 at 10:58 PM, Simon Michael si...@joyful.com wrote: A very common problem with online docs is fragmentation. Absolutely! Is it possible to include non-haddock documentation in a cabal package. Is it possible to have it readable on Hackage? I think this would help with the fragmentation and versioning issues. One option is to have haddock-only modules for non-reference documentation (xmonad-contrib does this), and I think at the moment it is a good option, but it does have disadvantages. It may not be clear from the outline where documentation can be found, and it clutters up the module namespace. Perhaps we could add support for a Documentation-Modules field in cabal files, which would separate these modules in the outline, and not install them but only their documentation. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell image libraries
Haskellers, To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format) Preferably, it should be possible to construct images programmatically too. Is there really no such library? It would be nice to have something like a Haskell equivalent of the Python Imaging Library, which is the de facto standard image library in Python and supports just about every type of operation on images you could ask for. Regards, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: fdo-notify 0.1, a client for the Desktop Notifications protocol
Haskellers, I present to you fdo-notify, a client library for FreeDesktop.org's Desktop Notifications protocol. This is the DBUS protocol served by NotifyOSD and other notifications systems, which allows a wide variety of applications to present notifications to the user in a uniform way. The library should not require knowledge of DBus or the Desktop Notifications protocol itself, at least once fully documented (there should be enough haddocumentation for basic use already). Hackage: http://hackage.haskell.org/package/fdo-notify Mercurial: http://bitbucket.org/taejo/fdo-notify/ Basic notifications and updated/replacement notifications are supported. Images are not yet supported (adding support should be easy, but which Image type? Is there a de facto standard imaging library like the Python Imaging Library?) and nor are signals. Signals allow an application to be informed when some action is taken on the notification (NotifyOSD doesn't support actions, but other implementations might). The library is released under the 3-clause BSD license, but depends on the dbus-core and dbus-client libraries which are GPLed. I hope you find this library useful. Regards, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell Weekly News: Issue 137 - October 31, 2009
On Mon, Nov 2, 2009 at 6:42 AM, Benjamin L.Russell dekudekup...@yahoo.com wrote: Hey, careful now No need to start another Emacs vs. the other 'editor' flamewar ... lest someone run M-x nethack and summon a Demogorgon against you ... er, make that M-x haskellhack, since a Haskell version needs to be created. ;-) There's MazesOfMonad on Hackage, Roguestar at http://roguestar.downstairspeople.org/, and I think there are more on Hackage too but it's still down. -- Benjamin L. Russell --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Weekly News: Issue 134 - October 10, 2009
Why don't you subscribe to haskell? It's much lower volume, and I think it's a better option than taking -beginners off-topic. --Max On Sun, Oct 11, 2009 at 2:10 PM, Patrick LeBoutillier patrick.leboutill...@gmail.com wrote: Hi, Could/should the Haskell Weekly News be posted to the beginners list as well? I normally don't follow haskell-cafe (too much traffic and generally above my level I must admit...), but I like to follow what's going on in the Haskell community. Patrick ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell for Physicists
On Wed, Sep 30, 2009 at 9:24 PM, Alberto G. Corona agocor...@gmail.com wrote: Haskell: mathematics beyond numerical calculus I'd imagine most physicists know a fair bit of mathematics beyond numerical calculus; what they might not know much about is *computation* beyond numerical calculus. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell for Physicists
I am *not* a physicist, but I imagine many physicists know at least something of functional analysis, algebra, Lie algebras, etc. However, when physicists write programs (this is my inference from the widespread use of Fortran and the computational assignments given to undergraduate students) they are almost exclusively numerical: very often evaluating some integrals or integrating a system of differential equations. Although Haskell can do these things, it's not a place where Haskell really shines (compared to symbolic computation). Since I'm not a physicist, I can't give a good example, but think more of the things Mathematica is good for, rather than Fortran or Matlab. My impression is that Haskell's advantage over Mathematica is in its generality: Mathematica is great if it has a builtin function to do what you want, but it's not a very pleasant programming language. HTH, Max On Wed, Sep 30, 2009 at 9:39 PM, Khudyakov Alexey alexey.sklad...@gmail.com wrote: В сообщении от Среда 30 сентября 2009 23:29:32 Max Rabkin написал: On Wed, Sep 30, 2009 at 9:24 PM, Alberto G. Corona agocor...@gmail.com wrote: Haskell: mathematics beyond numerical calculus I'd imagine most physicists know a fair bit of mathematics beyond numerical calculus; what they might not know much about is *computation* beyond numerical calculus. Could you elaborate this. As physicist I don't quite get it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why these two are not equivalent?
On Sat, Sep 12, 2009 at 9:52 PM, Diego Souza dso...@bitforest.org wrote: I assumed Data.Map was a tree internally and keep elements ordered, so the following would sort the input and print duplicates in O(n log n), as the C++ version does: sbank :: [B.ByteString] - [(B.ByteString,Int)] sbank = toAscList . fromListWith (+) . flip zip (repeat 1) Is it wrong to assume this? It worked for all tests cases I could think of though. That is part of the contract of toAscList (the Asc stands for ascending order), but because of the way Map is implemented, the result of toList is also sorted. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Darcs and NFS Resolution
On Sat, Sep 12, 2009 at 5:22 PM, Trent W. Buck trentb...@gmail.com wrote: Ew. I'm not keen on calling mv(1) to handle each rename, let alone via sh (which WILL explode on some paths, and allow injection attacks). rawSystem does not use sh (hence the raw) --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mapping over multiple values of a list at once?
My first approach would be to generate the list of sliding windows: [[4,3,2],[3,2,6],[2,6,7]] after importing Data.List: map (take 3) . tails $ [4,3,2,6,7] [[4,3,2],[3,2,6],[2,6,7],[6,7],[7],[]] Not quite what we want, but close: filter ((== 3) . length) . map (take 3) . tails $ [4,3,2,6,7] [[4,3,2],[3,2,6],[2,6,7]] So (filter ((== 3) . length) . map (take 3) . tails) seems to be the desired function. Now just map average. However, we don't really need the sliding windows themselves, just the sliding sum. There might be a slightly more efficient way to do that, but I'll leave it as an exercise for you or somebody else. --Max On Thu, Aug 27, 2009 at 10:19 AM, hask...@kudling.de wrote: Hi, Imagine you have a list with n-values. You are asked to iterate over the list and calculate the average value of each 3 neighbouring values. For example, starting from [4,3,2,6,7] you need to find the averages of 4,3,2 and 3,2,6 and 2,6,7 resulting in [3,4,5] What is the most elegant way to do that? The naive ansatz to use (!!) excessively sounds pretty inefficient. Bye, Lenny ___ 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
Re: [Haskell-cafe] Re: Thinking about what's missing in our library coverage
On Tue, Aug 4, 2009 at 6:13 PM, Magnus Therningmag...@therning.org wrote: AFAIU the plan is to separate GHC and its platform packages, so in the future it might not be that easy to get to the point where you _can_ run 'cabal install'. Absolutely not. The point of HP is to make the path from bare OS to complete Haskell installation including cabal-install consist of a single step: 1. Install Haskell Platform This is a good point, but to some extent this brings us back to a discussion that's specific to systems with broken or non-existing package managers. Wouldn't it be better to deal with _that_ outside of HP? AIUI, on systems with working package managers, HP will be a metapackage which depends on the appropriate real packages. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Thinking about what's missing in our library coverage
On Tue, Aug 4, 2009 at 11:56 PM, Magnus Therningmag...@therning.org wrote: AIUI, on systems with working package managers, HP will be a metapackage which depends on the appropriate real packages. Yes, but again, the role of HP shouldn't be to limit the pain of installing bindings to C libraries. What I'm saying is that it's a worthwhile goal to limit that pain, but it should be handled outside of HP. How could one do that? On systems with package managers, the platform won't bundle C libraries, but depend on them (this is correct: if software does in fact depend on a C library, it should declare that dependency). On systems without package managers, we could provide some form of sub-platform containing C libraries or a system for installing them, but then installing a Haskell system is no longer a one-step process. It's been a while since I was a regular Windows user, but it seemed then that bundling dependencies was the most common (only?) solution. /M --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Simple quirk in behavior of `mod`
2009/7/23 Matthias Görgens matthias.goerg...@googlemail.com: Couldn't the same be said for round-to-even, instead of rounding down like every other language? I doubt any beginners have ever expected it, but it's probably better. What do you mean with round-to-even? For rounding down there's floor. Round-to-even means x.5 gets rounded to x if x is even and x+1 if x is odd. This is sometimes known as banker's rounding. The most common alternative is round-half-up. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b question: defining datatype
On Thu, Jul 23, 2009 at 8:43 PM, Iain Barnettiainsp...@gmail.com wrote: data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] } But that's not really right, because obviously, some tasks don't have subtasks. The empty list is a list. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Python vs Haskell in tying the knot
On Wed, Jul 15, 2009 at 7:33 PM, Cristiano Pariscristiano.pa...@gmail.com wrote: fib = 1:1:fib `plus` (tail fib) where plus = zipWith (+) Of course, this was something I already encountered when exploring the Y-combinator. Anyhow, I tried to translate this implementation to Python using Iterators and this is what I wrote: def fib(): yield 1 yield 1 p = plus(fib(),tail(fib())) while True: yield p.next() def plus(x,y): while True: yield x.next() + y.next() print take(5,fib()) I'm not convinced that this is the same program as the Haskell version. No knot is tied in the Python version. To tie the knot, a data structure must contain or refer to itself. In the python version, the function which creates the data structure refers to itself, but many copies of the data structure are created. So my considerations are: 1 - The Fibonacci generator is not an example of TTK at all and then it can be translated to Python. This indicates that you think tying the knot should be impossible in Python. In my opinion this is not the case. By my definition of tying the knot, one needs *either* mutable variables or laziness (at least in simple cases). Since Python has the former, it is possible to tie the knot in Python. To me the simplest example of TTK in Python (not possible in Haskell because it has an infinite type): x = [] x.append(x) (If you try to print this list, one gets [[...]] in the standard REPL and [Recursion on list with id=173852620] in ipython) --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] homomorphic encryption and monads?
On Wed, Jul 15, 2009 at 11:54 PM, Jason Dagitda...@codersbase.com wrote: Hello, I have just a very vague understanding of what homomorphic encryption is, but I was wondering if homomorphic encryption behaves as a one-way monad (like IO). An interesting idea. Let's see where this leads. I could be mistaken about the way this works, but it seems that isSpam can't return a plain 'Bool' because then you could know things about the encrypted data without having to decrypt it first. So that is why I think it has to return Cypher Bool. Yes, this is the idea behind homomorphic encryption: you can do some work on an encrypted input, and get an encrypted output. Your categorical spidey-sense should be tingling right now, and indeed it did, but you interpreted it wrong (but it's a common trap) And because it's a homomorphic encryption, you could have something like doWork: doWork :: Cypher a - (a - b) - Cypher b Looks good. This type should send your spidey-sense into the red. Which we could use to implement isSpam: isSpam s = doWork s spamTest where spamTest :: String - Bool Thinking about it a bit more, since we never have to decrypt the data to work with it, it seems that (a - b) is wrong as well, because we don't have the key or whatever to do the decrypting. (a - b) is not wrong. Homomorphic encryption gives you exactly this *magic* function that takes an ordinary f :: a - b, and applies it to a Cypher a, giving you a Cypher b. No deciphering happens. The function get lifted/mapped into Cypher. So, then it seems reasonable that the only type for doWork is this: doWork :: Cypher a - (Cypher a - Cypher b) - Cypher b Which doesn't really seem all that useful now. Indeed. That is just (a restricted version of) the type of 'flip ($)', a rather uninteresting (though not useless) function. On the other hand, maybe we have an algorithm which can take a function on normal values and gives us a function on Cypher values: enCypher :: (a - b) - Cypher a - Cypher b This is exactly what you have. This is just the flipped version of your first doWork. And this function is better known as fmap. Cypher is a Functor. Because they have special syntax, are widely used in IO, and have a scary name (and perhaps for other, better reasons too), Monads seem to attract special attention. Functor and Applicative get much less love, but both are valuable and interesting typeclasses (they form a hierarchy: every monad is an applicative functor, and ever applicative functor is a functor). And hopefully your spidey-sense now has a Functor-detector :) I was planning to show that Cypher can't be a monad or an applicative functor, but their seems to be a hole in my thinking. Hopefully I can fix it, and hopefully everything I've said up to now has been correct. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell
2009/7/7 Antoine Latter aslat...@gmail.com: If I were writing it as a library function, I would leave the function as you described and let the caller make the choice. Calling into randomIO in a library function is extremely dubious, as a second library could be getting and setting the random seed used by randomIO (see setStdGen). So I'm okay taking on that risk in an application I write, but I'm not okay shipping that risk in a re-usable library, with the risk hidden behind a type signature. Maybe I'm just paranoid. You're not paranoid if they're really out to get you. I have been in a similar situation (on the other side: I discovered the flaw, and demonstrated an attack). I was in a Python class where our final project was a fairly fully-featured battleships game (3d graphics, network play and a computer player). Part of the evaluation (and a very fun part of the project) was an AI tournament. The TA gave us the code for the tournament server beforehand to that we could test our programs, and I observed that each player was loaded as a module into the same Python process. Python has both a global RNG and encapsulated RNG objects, but since it's an imperative language it's natural to use the global one and most people did. So one could seed the RNG at the start of each game to ones advantage: I tried this afterwards and beat all my opponents convincingly (in the real contest, where I didn't cheat, I was roughly equal to the two other top players and came second). Antoine --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK
On Sat, Jul 4, 2009 at 8:38 PM, Andrew Coppinandrewcop...@btinternet.com wrote: A few reasons: 1. I never knew it existed. ;-) A good reason. However, it's good to do a quick search over Hackage before uploading (or before writing) so you know what's out there. Also, if you hadn't used an AC- prefix, you'd have had a name collision. Is there a particular reason why you want your name in the package name rather than just the author field? 2. It's mind-blowingly complex. Colour *is* complex. Which is why I'm so glad Russell O'Connor did all the hard work for me :) 3. It doesn't appear to provide arithmetic over colours. It provides darken, blend and addition (though addition is called mappend rather than (+)). signum, abs and fromInteger don't make a huge amount of sense for colours. 4. It's parameterised over the component type; my library is hard-coded to specific types for speed. My feeling would be to trust the specializer until it lets me down. Has it let you down in the past? BTW, the EasyRaster package looks useful. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK
On Sat, Jul 4, 2009 at 9:18 PM, Andrew Coppinandrewcop...@btinternet.com wrote: 2. It's mind-blowingly complex. Colour *is* complex. Which is why I'm so glad Russell O'Connor did all the hard work for me :) Well, no, because now I'm going to have to spend a few hours trying to find out what CIE is before I can even use that library. The sRGB function makes a Colour from RGB (actually sRGB, which is a standardised RGB -- basically RGB where the exact frequency and power of each channel is specified -- but you can pretend your monitor's RGB is sRGB. So mappend gives you colour addition [with the perplexing comments about gamut, presumably some kind of small mammal?] The gamut of a device is the range of representable colours (a monitor's gamut looks something like a parabola with a flat base in XYZ space, whereas a printer's is much more complex and variable). This makes sense. If you double a monitor's brightest white, you don't get a colour twice as bright: you get the same colour. but there's no subtraction? No multiplication? No linear blending? affineCombo can do subtraction, again with the gamut warning. darken does scalar multiplication; it probably doesn't do componentwise multiplication, which doesn't make much sense if you're trying to work in a coordinate-independent setting, though I admit RGB-multiplication can be handy. Heh, my colour library includes a custom floor implementation that talks to the GHC primops directly because calling floor is too slow... [In case that sounds like idle talk, I had a program go from 10 seconds to less than 1 second just by using this function. There's a few tickets about it on the GHC Trac.] Fair enough. Can your implementation not be turned into a patch? BTW, I'm also working on Haskell fractals. You might be interested in looking at my fractal package (though it's currently undocumented, and has no GUI). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Half-integer
On Sun, Jun 28, 2009 at 9:29 PM, Andrew Coppinandrewcop...@btinternet.com wrote: Which versions of base have you tested it with? :-) Whichever one GHC 6.10.3 ships with... ghc-pkg list base will tell you which version you have installed. Frankly, I highly doubt it makes any difference either way. (Does anybody know how base3 differs from base4?) It only uses a few type classes from the Prelude... If it *only* uses the prelude (i.e., does not include *any* modules), then it should work with any version of base. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Another question about unsafePerformIO
On Thu, Jun 25, 2009 at 3:49 PM, John Meachamj...@repetae.net wrote: However, if the algorithm takes a signifigant amount of time or resources, you may want to keep it in IO just so users can have control over exactly when and how often it is run. If you had a pure function written in Haskell that used a lot of time and memory, would you put it in IO just so users can have control over exactly when and how often it is run? bigFatFunction :: Foo - IO Bar bigFatFunction x = return . bigFatFunction $ x If the function really does use a lot of time and memory and your compiler is duplicating calls to it, then you have a pessimizing compiler and should file a bug. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ICFP contest
I'm part of a fairly large team. I'm the only person on the team who's done more than Project Euler problems in Haskell, so we'll probably only use Haskell if there's a library or program that does exactly what we need for some task. Likely we'll be using Perl and Python, and C++ if there's any heavy lifting to be done. --Max 2009/6/23 Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp.li...@gmail.com: Hi, The good folks here are really quiet about the ICFP Contest. Is anyone participating this year? As in the previous four years, I will probably download the problem, take a look, and try for a while... Having a family don't allow me to go much further, especially when teaming up with myself! Best regards, Rafael Gustavo da Cunha Pereira Pinto ___ 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
Re: [Haskell-cafe] How to determine if a FilePath is a directory name or regular file?
On Mon, Jun 22, 2009 at 2:09 PM, Deniz Dogandeniz.a.m.do...@gmail.com wrote: I think see what you mean, but I find the argument more of an excuse to the poor naming than a solid argument for it. Following the convention and intuition that most users have should be more important than making the (sometimes unnecessary) distinction between a directory and the path to it. I disagree. (isDirectory /no/such/directory/) should equal true: the given FilePath is a directory path (on Unix), since it ends with a slash. However (doesDirectoryExist /no/such/directory) should return false, since there is no such directory. -- Deniz Dogan --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to determine if a FilePath is a directory name or regular file?
On Mon, Jun 22, 2009 at 2:54 PM, Deniz Dogandeniz.a.m.do...@gmail.com wrote: Are you saying that when a function is named isDirectory you expect it to only check for a trailing forward slash character? No. I'm saying that *if* isDirectory existed, then (isDirectory /no/such/directory/) should equal true on Unix. I'm saying isDirectory should not *exist*, because it cannot do what it says on Unix or Windows. There are OSes where it can do what it says (i.e., it is possible to tell whether a path points at a directory or a file). -- Deniz Dogan --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Installing agda through cabal
On Fri, Jun 19, 2009 at 11:20 PM, Paulo J. Matospocma...@gmail.com wrote: Shouldn't cabal make sure the library it installs are in PATH? This would require modifying the path (since there may be no writable location on the existing path). But the PATH is set by a combination of several programs written in Turing-complete languages (shell script), and those programs themselves are in unknown locations (depending on the shell in use). or at least, they are in the PATH of the apps built by cabal itself? This is a possibility. But surely you're one day going to want to run your cabal-installed programs yourself (there are some pretty handy ones), so the easiest thing is to extend your path. It might be a good idea for cabal-install to warn that its bin directory is not in your path when you install an executable. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
On Wed, Jun 17, 2009 at 1:07 PM, Henk-Jan van Tuylhjgt...@chello.nl wrote: On Wed, 17 Jun 2009 10:38:23 +0200, Yitzchak Gale g...@sefer.org wrote: An improved reverse function: reverse' = foldl' (flip (:)) [] There is no need for reverse to be lazy, so this one could replace the original one. reverse' is not too strict: Data.List let reverse' = foldl' (flip (:)) [] in head $ reverse' [undefined, 1] 1 Since reverse' is polymorphic in the type of list elements, the only way it could be strict in the *elements* is if it applied seq to them. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] web musing
On Fri, Jun 5, 2009 at 5:18 PM, Conor McBrideco...@strictlypositive.org wrote: Will I need to ask systems support to let me install some haskelly sort of web server? Looks likely, I suppose. In general, what's an easy way to put a web front end on functionality implemented in Haskell? For something this simple, I'd use CGI. I've never used the Haskell cgi package, but the basic idea is that the webserver runs an arbitrary script which reads the HTTP request information from environment variables, and outputs the response (in the simple case, just Content-Type: text/html\r\n\r\n++html). The cgi package probably provides easy access to those environment variables; this is what Python's cgi module does, for instance. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [] == []
On Fri, May 29, 2009 at 12:29 PM, Paul Keir pk...@dcs.gla.ac.uk wrote: f''' = ([]::[()]) == ([]::[()]) (Very pretty.) So why doesn't ghc have 'default' instances? It does. I believe Num defaults to Integer and then to Double. Generally, though, defaults are convenient in exploratory usage but confusing in compiled code. In compiled code, you don't want arbitrary choices of defaults to affect performance and correctness. I've had programs run much slower than expected because the types defaulted to Integer rather than Int. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Beginner SOS
Hi Manu Depending on your style, you might prefer Real World Haskell (available online or in print) or Learn You A Haskell (http://learnyouahaskell.com/). Of course, there are others, but my personal preference is for LYAH. --Max On Wed, May 27, 2009 at 7:14 PM, Manu Gupta manugu...@gmail.com wrote: Dear anyone, I wish to learn HASKELL. However my institution does not teach it so plus I don't have a clue how to get around with it. Everything seems so unconventional and out of place Can you help me out in getting good tutorials that will help me to learn HASKELL by myself so that I can pursue it as a serious programming languages Till now I have referred Haskell wiki and have tried everywhere but does not seem to learn it PLZ, PLZ HELP ME OUT -- Regards MANU ___ 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
Re: Re[2]: [Haskell-cafe] Strange type error with associated type synonyms
On Wed, May 27, 2009 at 9:59 PM, Bulat Ziganshin bulat.zigans...@gmail.com wrote: Hello Simon, Wednesday, May 27, 2009, 11:42:22 PM, you wrote: while we are here - i always had problems understanding what is inferred and what is expected type. may be problem is just that i'm not native speaker are other, especially beginners, had the same problem? The inferred type of e is the type that the compiler thinks e has. The expected type is the type it *should* have, given its context. Consider: f :: Int - Int then the expression (f True) has a type error: Couldn't match expected type `Int' against inferred type `Bool' In the first argument of `f', namely `True' GHC is saying the first argument of f *should* be an Int, but it seems to be a Bool. As to whether it's confusing, I sometimes have to read these messages a few times (sometimes it's unclear which expression is being referred to, or why GHC thinks that the expression has a certain type), but the words themselves are clear in their meaning to me. HTH, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[4]: [Haskell-cafe] Strange type error with associated type synonyms
On Wed, May 27, 2009 at 10:28 PM, Bulat Ziganshin bulat.zigans...@gmail.com wrote: can you recall early times of your work with GHC? i think that these words are non-obvious for novices. finally it becomes part of your instincts as anything else often used. but it can be learning barrier. overall, hard-to-understand error messages was elected as one of 3 most important GHC problems in the survey conducted several years ago I don't remember having any trouble, but that was a few years ago, and type errors are confusing generally. I think that the main difficulty with type errors is not the error *messages*, but I'm sure there is room for improvement. Do you have any ideas? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Error message reform (was: Strange type error with associated type synonyms)
On Wed, May 27, 2009 at 11:05 PM, Bulat Ziganshin bulat.zigans...@gmail.com wrote: i mean just changing the words to make obvious what type was got in what way. and check it on beginners who don't yet read your explanations, for example teachers may test it on their students my English is limited... for example, it may be like this: read x Error: type of x is Integer while type of read argument should be String For me, this word order is an improvement, but it doesn't help to leave out the words expected and inferred. To me, those words add explanation. Of course they don't help if you don't know what they mean. I think they add something because they explains where the types came from. When I get type errors, I often think why do you say True has type Bool (of course in most cases it is not so transparent). Although the compiler doesn't say *why* it inferred that type, at least it says it did infer it. I prefer this wording: The inferred type of `True' is `Bool', while the type of the first argument of `f' should be `Int'. In the expression: f True I prefer all three to Hugs's ERROR - Type error in application *** Expression : f True *** Term : True *** Type : Bool *** Does not match : Int --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Error message reform (was: Strange type error with associated type synonyms)
On Thu, May 28, 2009 at 12:03 AM, Jeff Wheeler j...@nokrev.com wrote: I absolutely agree about expected/inferred. I always forget which is which, because I can figure both could apply to each. That's actually true for me too. When you say it like that, I remember times when I've had the same confusion. Better language may be much more helpful, although I'm not sure what may be easier to interpret. I think one big improvement (demonstrated in Bulat's proposal) is to put the two types near where those types come from. GHC gives you the two types, and then the context in which they arose. Hugs gives the context and then two types, but doesn't say which type is which. So we say: you have here `True', it is a `Bool'. But the first argument of `f' should be an `Int'. Thus it's clearly indicated where the two types came from. My preference is still to include the words expected and inferred which indicate (to me) that *either* could be wrong. And they don't seem to me to be compiler writers' jargon. They're both ordinary (if not everyday) English words. But definitely we should use language which more clearly indicates which is which. I'll pay more attention to error messages in the future. GHC devs: would patches for error message language be considered? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] May all logos be freely used?
From http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas : Please submit your entries here, and attach your name to them please. To be eligible, they will need to be visible on this page (e.g. uploaded, or link to the image). The image should be freely available (a suitable freely distributable license). Entries not displayed here won't be eligible. And the wiki license: By contributing to HaskellWiki, you license your contribution under this license: Permission is hereby granted, free of charge, to any person obtaining this work (the Work), to deal in the Work without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Work, and to permit persons to whom the Work is furnished to do so. THE WORK IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS IN THE WORK. Contributions since 2006-01-14 05:15 UTC are available under the above license. So at least any logos on the wiki should be usable under that license. --Max On Tue, May 26, 2009 at 6:31 PM, Hans van Thiel hthiel.c...@zonnet.nl wrote: Hello, What's the status of the logos on http://www.haskell.org/logos/results.html I'd like to use one or more in an about message in a Haskell program. Is this allowed, and if so, are there any conditions? I've just looked at them again, and it's a really fine collection, I think. Best Regards, Hans van Thiel ___ 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
Re: Re: [Haskell-cafe] Re: A problem with par and modules boundaries...
On Sat, May 23, 2009 at 7:31 PM, Mario Blažević mblaze...@stilo.com wrote: Does anybody know of a pragma or another way to make a function *non-strict* even if it does always evaluate its argument? In other words, is there a way to selectively disable the strictness optimization? parallelize a b | False = (undefined, undefined) | otherwise = a `par` (b `pseq` (a, b)) might do, unless strictness analysis is smart enough to know that the False guard is always, well, False. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hiddenness
On Thu, May 14, 2009 at 10:51 PM, Vasili I. Galchin vigalc...@gmail.com wrote: Hello, When I am compiling a module, I get Could not find module 'Control.Module.State': it is a member of package mtl-1.1.0.2, which is hidden 1) What is the efficacy of hiddenness? As I understand it, the purpose is two-fold. Firstly, if you have multiple versions a package (or multiple packages containing the same module), you can hide the ones not in use. Second, it ensures you have declared all dependencies. 2) I have forgotten what tool I run to expose a package. ?? I've only ever had this when working with Cabal, where I have missed a dependency. In this case, it looks like you have an undeclared dependency on mtl. I'm not sure whether this arises in the non-Cabal case. 3) In another vein, the code is using Data.Finitemap ... so I guess I must darcs install this? I believe it was just uploaded to Hackage (it's obsolete, but useful for getting old code to run). HTH, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Map.Map Pattern Matching
On Wed, May 13, 2009 at 7:06 PM, Nico Rolle nro...@web.de wrote: Hi I tried this but it diddn't work in ghci: import qualified Data.Map as Map test :: Map.Map [Int] [[Int]] - Bool test (fromList[((i:is), (j:js))]) = [i] == j i get the : Parse error in pattern Failed. error. fromList is an ordinary function. Pattern-matching only works on constructors (unless you use view patterns [see http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns]). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stream-fusion without the lists
On Tue, May 12, 2009 at 1:39 PM, Roman Leshchinskiy r...@cse.unsw.edu.au wrote: let xs = map f ys in (sum xs, product xs) the elements of xs will be computed once if it is a list but twice if it is a stream. If you're using lists for loops rather than data, that's what you want (what you probably really want is cfoldl' ((,) $ sumF * productF) xs, in terms of combinable folds). Roman --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] commending Design concepts in programming languages
On Tue, May 12, 2009 at 1:41 PM, Wolfgang Jeltsch g9ks1...@acme.softbase.org wrote: At least, I cannot remember seeing the other notation (first morphism on the left) in category theory literature so far. It’s just that my above-mentioned professor told me that category theorists would use the first-morphism-on-the-left notation. I've seen the notation f;g for g.f somewhere (and Wikipedia mentions it). I think it's less ambiguous than just fg (which I've seen for f.g too), but in Haskell we have the option of . A flipped application might be nice to go with it. How about $ ? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: OT: Languages
On Sun, May 10, 2009 at 6:44 AM, wren ng thornton w...@freegeek.org wrote: Kalman Noel wrote: Esperanto, on the other hand, is usually described as agglutinative. I'll take your word for it :) Consider malsanulejestro (the head of a hospital): mal-san-ul-ej-estr-o (un-health-person-place-leader-noun, or leader of the place of unhealthy people). --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Being impure within a 'pure' function
On Wed, Apr 22, 2009 at 10:38 AM, Daniel K. anmeldema...@gmail.com wrote: Dijkstra's algorithm ... relies heavily on mutating arrays Well, the imperative implementation does. Not mutating the underlying arrays would probably result in poor performance. Indeed. Non-mutable arrays are not very performant for mutations. Tree-like data structures Are Your Friend. I've never compared the performance of an ST-based implementation with a set/map based algorithm, but I've often found the latter usably performant. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for the fastest Haskell primes algorithm
On Tue, Apr 14, 2009 at 2:47 PM, Andrew Wagner wagner.and...@gmail.com wrote: Some other ideas for things to put in this package possibly: is_prime :: Int - Bool I'd also add isProbablePrime using a Miller-Rabin test or somesuch, for use with large numbers. It'd have to be in a monad which supplies randomness, of course. But to start with, I'd just package what I had and put it on Hackage. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: SVGFonts 0.1
On Mon, Apr 6, 2009 at 7:32 PM, Tillmann Vogt tillmann.v...@rwth-aachen.de wrote: It is a real library made of pure Haskell. What is wrong with my .cabal file? The issue is not about whether it is pure Haskell. You have simply marked it up as an executable rather than a library. Executable Fonts Main-is:test/Fonts.hs Build-Depends: haskell98, base, OpenGL, GLUT, xml, parsec --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The votes are in!
On Tue, Mar 24, 2009 at 11:41 PM, Henning Thielemann lemm...@henning-thielemann.de wrote: http://www.cs.cornell.edu/w8/~andru/cgi-perl/civs/results.pl?num_winners=1id=E_d21b0256a4fd5ed7algorithm=beatpath Is there also a measure of how strong the winner wins over the losers? The runner up was beaten 135 votes to 100. The linked page gives the results of the one-on-one contest between each entry and the winner, as well as between each entry and the next better one. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] random-shuffle package
On Thu, Mar 19, 2009 at 4:41 PM, Manlio Perillo manlio_peri...@libero.it wrote: However, in this case, the package name should be changed. I'm not sure it is a good idea to release a package that implements only one function (but I may be wrong). Personally, I think that there is little harm in releasing a package if it does something useful in a not-totally-broken way. Especially if you plan to extend it. I wrote the hmm package, which is basically only two functions, but that's all one needs to work with hidden Markov models, so that's all there is (I *am* busy expanding its functionality that's needed in a program I'm writing, but the basics are already there). I also uploaded the kmeans package, which exports a single function -- a friend of mine had the code, and it was useful to me, so it might be useful for others. And what does a clustering package need besides a cluster function? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?
2009/3/11 R J rj248...@hotmail.com: 2. I believe that the reverse implementation--namely, implementing foldr in terms of foldl--is impossible. What's the proof of that? That's correct. Consider their behaviour on infinite lists. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to create an online poll
On Wed, Feb 18, 2009 at 10:40 PM, Anton van Straaten an...@appsolutions.com wrote: There's also the Condorcet Internet Voting Service: http://www.cs.cornell.edu/andru/civs.html This looks like exactly what we need! Any objections? --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lazy evaluation is not complete
On Mon, Feb 9, 2009 at 10:50 PM, Iavor Diatchki iavor.diatc...@gmail.com wrote: I 0 * _ = I 0 I x * I y = I (x * y) Note that (*) is now non-commutative (w.r.t. _|_). Of course, that's what we need here, but it means that the obviously correct transformation of foo x = if x == 0 then 0 else foo (x - 1) * foo (x + 1) into foo' x = if x == 0 then 0 else foo' (x + 1) * foo' (x - 1) is *not* in fact correct. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The Haskell re-branding exercise
On Sun, Feb 8, 2009 at 8:57 AM, Gwern Branwen gwe...@gmail.com wrote: We should limit voting, and limit based on IP. If we go via email, then anyone wishing extra votes merely needs to use mailinator.com (and its dozens of alternate domain names, to say nothing of competitors providing similar services) to vote as many times as they want. If we care about fraud, then it would be a very troublesome task to filter out all those ways to fraudulently vote; if we don't care about fraud, then email confirms are just a burden on honest users. I don't know about other people, but for me it takes less time to change IP addresses than to sign up for a mail account. dhclient -r dsl0 dhclient dsl0 vs. fill in a form on a webpage. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haddock Markup
On Fri, Feb 6, 2009 at 12:17 PM, Lennart Augustsson lenn...@augustsson.net wrote: It doesn't really matter if TeX is a good or bad idea for writing maths. For our users, they might do a formula if it's TeX, they won't if it's something else. Generally, I'd agree, but I just took a look at AsciiMathML, and it's pretty TeX-like. Personally, I'd consider using it, if it meant I could get decent-looking formulae in my HTML Haddocks. -- Lennart --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just how unsafe is unsafe
2009/2/5 Peter Verswyvelen bugf...@gmail.com: Of course you could just put this random generator in the IO monad, but certain algorithms- like Monte Carlo - intuitively don't seem to operate in a IO monad to me. For PRNGs, only State is needed, not IO. But you might find the `randoms' function useful: it returns in infinite list of pseudo-random values. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haddock
On Thu, Feb 5, 2009 at 4:25 PM, David Waern david.wa...@gmail.com wrote: As for running arbitrary commands, I think we are opening up to a lot of unfamiliar syntax. I'd like to hear what everyone thinks about that. I personally find it useful to have Haddock comments readable in the source. And aren't there security issues, too? So we'd have to have an option to disable them, which would have to be on by default, and basically they would be disabled by everybody but the writers of the comments themselves. --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] about integer and float operations
On Wed, Feb 4, 2009 at 1:09 PM, Manlio Perillo manlio_peri...@libero.it wrote: In Haskell, something like (/) :: (Num a, Real b) = a - a - b You probably want (Real a, Fractional b) = a - a - b. Int is an instance of Real... Real is the class of types that can be converted to Rational. Then we can define (/.) :: (Real a1, Real a2, Fractional a) = a1 - a2 - a x /. y = fromRational $ toRational x / toRational y whose type is more general than the one I gave above, but we can restrict it to that by changing the signature, if you like. (//) :: (Num a, Integral b) = a - a - b Again, Num is inappropriate, but we can define something similar: (//) :: (Integral b, Real a, Real a1) = a - a1 - b x // y = floor $ toRational x / toRational y Hope that helps, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe