Re: [Haskell-cafe] Style

2007-08-26 Thread Yitzchak Gale
Bjorn Bringert wrote: Here's a much more inefficient version, but it has the merit of being very easy to understand: tm_silly n = length $ takeWhile (=='0') $ reverse $ show $ product [1..n] Be careful with types - use Data.List.genericLength here instead of length. Otherwise, tm_silly n is

Re: [Haskell-cafe] Style

2007-08-26 Thread Yitzchak Gale
I wrote: Be careful with types - use Data.List.genericLength here instead of length. Otherwise, tm_silly n is wrong for n = 13 (on my 32-bit machine) due to round-off error in the Int type. Are you sure you really tested tm_silly ? length is perfectly enough to count the 0 in n! since the

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Yitzchak Gale
Hi Manu, You wrote: After reading Peter Norvig's take on writing a Sudoku solver (http:// norvig.com/sudoku.html) I decided that I would port his program to Haskell, without changing the algorithm, that'll make a nice exercise I thought and should be fairly easy... Boy, was I wrong !

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Yitzchak Gale
Manu wrote: Should I introduce more strictness ? replace lists with more efficient data structures (ByteStrings, Arrays) ? Derek wrote: Yes. Treating lists like arrays is always a recipe for heartbreak. Here it costs very little - the lists are all short, mostly of length exactly 9. If

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Yitzchak Gale
I wrote: Perhaps you would gain something if you used Data.Map.! instead of your lookup. Manu wrote: I'm not sure I understand, do you mean I should have use a strict Map constructor ? like : Map !key !value ? No, there is an operator in Data.Map called !. how can it replace the lookup

Re: [Haskell-cafe] Confusing type specialisation in ghci

2007-10-08 Thread Yitzchak Gale
David Carter wrote: Prelude let sqlist = map sq ... Prelude sqlist [2.5] interactive:1:8: No instance for (Fractional Integer) ... etc Isaac Dupree wrote: The dreaded Monomorphism Restriction... You could... use `ghci -fno-monomorphism-restriction`. ...it's good to know the

[Haskell-cafe] Some lambda identities

2007-10-09 Thread Yitzchak Gale
While playing with @pl on #haskell, I noticed some weird and surprising lambda identities. For example: let {c = (.); c4 = c c c c} Then we have: c c4 == c c4 c c c c Proof: Repeatedly apply the identity: (*) x (y z) == c x y z More stuff: c c2 == c4, c c3 == c7, but c cn does not appear to

Re: [Haskell-cafe] EnableGUI hack changes working directory

2007-10-09 Thread Yitzchak Gale
apfelmus wrote: Is there a way to automate ghci ... EnableGUI -framework Carbon and typing enableGUI at the first prompt? I have the following in my .ghci file: -- Read GHCI commands from the file whose name is -- in the GHCIRC environment variable :def _load

[Haskell-cafe] Re: Some lambda identities

2007-10-09 Thread Yitzchak Gale
I wrote: And flip is (essentially) the B combinator. Oops, the C combinator. -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] symbol type?

2007-10-10 Thread Yitzchak Gale
Michael Vanier wrote: Is there an implementation of a symbol type in Haskell i.e. a string which has a constant-time comparison operation? Stefan O'Rear wrote: Yes, I beleive GHC uses one (utils/FastString.lhs iirs) In some cases where you would need that in other languages, you would use an

Re: [Haskell-cafe] pi

2007-10-10 Thread Yitzchak Gale
Dan Piponi wrote: The reusability of Num varies inversely with how many assumptions you make about it. A default implementation of pi would only increase usability, not decrease it. If you need a specialized definition of pi in your instance, you would provide it, just as you do now. If pi

Re: [Haskell-cafe] symbol type?

2007-10-10 Thread Yitzchak Gale
Michael Vanier wrote: I'm thinking of a symbol type that can be used for a compiler... Ah. Perhaps Data.HashTable is what you are looking for then? -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: symbol type?

2007-10-10 Thread Yitzchak Gale
I wrote: Perhaps Data.HashTable is what you are looking for then? Jerzy Karczmarczuk wrote: extract from Data.Hash what you need... why not try tries? apfelmus wrote: There's always Data.Map Those are log n. I would personally use those for almost every application, but Mike says he wants

Re: [Haskell-cafe] Filesystem questions

2007-10-13 Thread Yitzchak Gale
Andrew Coppin wrote: Is there a way to get rid of . and .. in the results? Brandon S. Allbery wrote: Manual filtering is always required, whether C, Perl, Haskell, etc. I dunno, maybe python filters them for you or something. Correct, Python filters them out. This is clearly the correct

Re: [Haskell-cafe] Filesystem questions

2007-10-14 Thread Yitzchak Gale
I wrote: ...a tool for recursing through directories... How about a built-in function that represents a directory tree as a lazy Data.Tree? Bryan O'Sullivan wrote: See System.FilePath.Find in http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FileManip-0.2 Not a very good idea.

Re: [Haskell-cafe] Filesystem questions

2007-10-14 Thread Yitzchak Gale
I wrote: How about a built-in function that represents a directory tree as a lazy Data.Tree? Jules Bean wrote: Please no. The last thing haskell needs is more dangerous semantically broken non-referentially-transparent lazy IO structures. Agreed. I would definitely not want it to be a

Re: [Haskell-cafe] Filesystem questions

2007-10-14 Thread Yitzchak Gale
I wrote: ...a tool for recursing through directories... How about a built-in function that represents a directory tree as a lazy Data.Tree? Bryan O'Sullivan wrote: See System.FilePath.Find in http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FileManip-0.2 -- List all directories

[Haskell-cafe] Let's do ListT right, finally

2007-10-14 Thread Yitzchak Gale
Hi Ian, thanks for responding to my plea! I am renaming this thread and moving it to libraries. Please respond there. I wrote: http://haskell.org/haskellwiki/ListT_done_right and not the broken implementation that comes with mtl. (Finally fixed in 6.8? Please?) Ian Lynagh wrote: If you want

Re: [Haskell-cafe] Re: Filesystem questions

2007-10-14 Thread Yitzchak Gale
Hi apfelmus, I wrote: ...a tool for recursing through directories... How about a built-in function that represents a directory tree as a lazy Data.Tree? -- List all directories in the tree rooted at the given path traverseDirectories :: MonadIO m = TraversalDirection - FilePath - ListT m

Re: [Haskell-cafe] Filesystem questions

2007-10-14 Thread Yitzchak Gale
Hi Bryan, You wrote: This is little different from the approach taken by Python's os.walk, which lazily yields the contents of a directory tree as it traverses it. I'm a little unclear on why one appears good in your eyes, while the other is not, beyond perhaps the depth/breadth knob and

Re: [Haskell-cafe] Let's do ListT right, finally

2007-10-14 Thread Yitzchak Gale
David Menendez wrote: If desired, we could easily define a class for commutative monads, and then state that ListT m is only a monad if m is a commutative monad. If we do that, can I suggest that we use some name other than ListT for that? So far, we seem to agree that most practical

Re: [Haskell-cafe] Hosting of Haskell project

2007-10-15 Thread Yitzchak Gale
Magnus Therning wrote: There is support for darcs in tracs as well. Gour wrote: I was playing with it in the past, but it's 3rd party, ie. Trac does not have official support. I happen to be looking for a project mgmt framework right now. It seems to me that the opposite is true. Trac is a

Re: [Haskell-cafe] Strange subtract operator behavior - and lazy naturals

2007-10-17 Thread Yitzchak Gale
John Meacham wrote: if anyone is interested, Although I bet this has been implemented a hundred times over, I have attached my lazy naturals module below just for larks. Nice, lots of fun! Wouldn't it be more convenient to allow them to be signed? True, you can't have laziness in certain

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-17 Thread Yitzchak Gale
Tim Newsham wrote: A tutorial on the Curry-Howard Correspondence in Haskell: http://www.thenewsh.com/%7Enewsham/formal/curryhoward/ Nice! Perhaps you should add a link to this on the wiki: http://haskell.org/haskellwiki/Curry-Howard-Lambek_correspondence Thanks, Yitz

Re: [Haskell-cafe] Suspected stupid Haskell Question

2007-10-17 Thread Yitzchak Gale
Dougal Stanton wrote: It's just occurred to me that answering questions like these is a bit like the prisoner's dilemma... There's no way to win! :-) Yes there is. Just mention the following wiki page as part of your answer: http://haskell.org/haskellwiki/Homework_help -Yitz

Re: [Haskell-cafe] Suspected stupid Haskell Question

2007-10-17 Thread Yitzchak Gale
Peter Verswyvelen wrote: However, I suspect the experts here will be able to make that much shorter and more efficient (maybe using Data.Map?) That makes it difficult to respond. I am definitely not claiming to be an expert. For one thing, my name is not Simon. But I'll say something anyway,

Re: [Haskell-cafe] Suspected stupid Haskell Question

2007-10-17 Thread Yitzchak Gale
I wrote: When you can assume Ord, the standard solution is, as you suggest, something like... Oops, sorry, doesn't typecheck. Here it is corrected: import qualified Data.Map as M import Data.List histogram = M.toList . foldl' (\m x - M.insertWith' (+) x 1 m) M.empty This should work

Re: [Haskell-cafe] Suspected stupid Haskell Question

2007-10-17 Thread Yitzchak Gale
Is there a place where one can look up the complexity of Standard Libraries functions ? No. Some modules have it in their Haddock docs. Most don't. But the source code is available. :) -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: Suspected stupid Haskell Question

2007-10-18 Thread Yitzchak Gale
Hi Chad, Chad Scherrer wrote: I think the stack overflows were happening because Map.insertWith isn't strict enough. Otherwise I think the code is the same. They are visibly almost identical - except that you do an extra lookup to get your strictness, while insertWith' has internal access and

Re: [Haskell-cafe] Strange subtract operator behavior - and lazy naturals

2007-10-18 Thread Yitzchak Gale
I wrote: Nice, lots of fun! Wouldn't it be more convenient to allow them to be signed? John Meacham wrote: Well, a couple reasons. One is that Natural numbers are a pretty useful type in and of themselves, often times when used with lazy evaluation. The other is that it is unclear what

Re: [Haskell-cafe] Strange subtract operator behavior - and lazy naturals

2007-10-19 Thread Yitzchak Gale
Hi John, I wrote: - Zero really means 0, not 0 or negative You wrote: Actually, zero does mean zero. There is no such thing as negative numbers in the naturals so it doesn't make sense to say '0 or negative'. Well, then, 0 or error, or 0 or nothing. It clearly does not mean zero.

Re: [Haskell-cafe] Strange subtract operator behavior - and lazy naturals

2007-10-21 Thread Yitzchak Gale
I wrote: Yitzchak Gale wrote: So why not make the laziness available also for cases where 1 - 2 == 0 does _not_ do the right thing? data LazyInteger = IntZero | IntSum Bool Integer LazyInteger or data LazyInteger = LazyInteger Bool Nat or whatever. Luke Palmer wrote: data LazyInteger

Re: [Haskell-cafe] wordsBy in the base libraries?

2007-10-22 Thread Yitzchak Gale
Maxime Henrion wrote: This version takes care of avoiding a redundant character check It still has several redundant checks: s'' is known to begin with space if it is non-empty, but that is checked again in the recursive call of wordsBy. In fact, break already checked whether s'' is empty, but

Re: [Haskell-cafe] wordsBy in the base libraries?

2007-10-22 Thread Yitzchak Gale
Neil Mitchell wrote: You are still over by one test. Try instead: wordsBy :: (a - Bool) - [a] - [[a]] wordsBy p s = case dropWhile p s of [] - [] s':rest - (s':w) : wordsBy p (drop 1 s'') where (w, s'') = break p rest This still has the redundant empty list tests, and

Re: [Haskell-cafe] wordsBy in the base libraries?

2007-10-22 Thread Yitzchak Gale
Neil Mitchell wrote: ...Also remember that p may be arbitrarily expensive, while a test for an empty list is cheap. In the particular case of words, p (i.e. isSpace) is very expensive... A reasonable level of optimisation for this function would be that the predicate is invoked at most once

Re: [Haskell-cafe] XML parser recommendation?

2007-10-22 Thread Yitzchak Gale
Henning Thielemann wrote: HXT uses Parsec, which is strict. Is is strict to the extent that it cannot produce any output at all until it has read the entire XML document? That would make HXT (and Parsec, for that matter) useless for a large percentage of tasks. Or is it just too strict in

Re: [Haskell-cafe] XML parser recommendation?

2007-10-23 Thread Yitzchak Gale
Malcolm Wallace wrote: HaXml now uses the polyparse library, and you can choose whether you want well-formedness checking with the original strict parser, or lazy space-efficient on-demand parsing. Initial performance results show that parsing XML lazily is always better than 2x as fast, and

Re: [Haskell-cafe] XML parser recommendation?

2007-10-23 Thread Yitzchak Gale
Another question about HaXML and HXT - what is the level of XML spec. compliance? The many who have tried to implement compliant XML parsers in various languages - and the few who have succeeded - all agree that this is much harder than it seems at first. Most of the time, the final result is an

Re: [Haskell-cafe] ANNOUNCE: dataenc 0.9

2007-10-23 Thread Yitzchak Gale
Magnus Therning wrote: My collection of data encoding functions are now available Nice! Should this effort be coordinated with Unicode-related encoding/decoding? See the Encoding class in Twan van Laarhoven's CompactString library: http://twan.home.fmf.nl/compact-string/ and Johan Tibell's

Re: [Haskell-cafe] XML parser recommendation?

2007-10-23 Thread Yitzchak Gale
Malcolm Wallace wrote: I have been considering moving the lexer to use ByteString instead of String, which would neatly solve that problem too. Doesn't the lexer come only after decoding? Then you have Unicode. Does ByteString still help? -Yitz ___

Re: [Haskell-cafe] ANNOUNCE: zlib and bzlib 0.4 releases

2007-10-23 Thread Yitzchak Gale
Duncan Coutts wrote: I'm very happy to get feedback on the API, the documentation or of course any bug reports. It would be nice if the API could be the same for all character and data codecs. Thanks, Yitz ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Monte Carlo Pi calculation (newbie learnings)

2007-11-06 Thread Yitzchak Gale
Hi Alex, You wrote: I'm new to Haskell, and don't quite understand how IO and lazy evaluation work together yet. In order to improve my understanding, I thought I'd try to knock together a translation of a fairly simple problem I can code up in C... Now, I have two questions. The easy

Re: [Haskell-cafe] Monte Carlo Pi calculation (newbie learnings)

2007-11-06 Thread Yitzchak Gale
Hi Alex, I think I would have avoided most of the problems in the first place. I'm finding the documentation to be rather undiscoverable at the moment, but I'm sure it's just a question of learning my way around it. Make sure to keep http://haskell.org/ghc/docs/latest/html/libraries/ on

Re: [Haskell-cafe] Monte Carlo Pi calculation (newbie learnings)

2007-11-06 Thread Yitzchak Gale
I wrote: There is still a problem here - my code (and also all of the previous posters, I think) clobbers the random generator, rendering it unusable for future calculations. In this case that is probably not a problem, but it is a bad habit to get into, and not very polite. Jonathan Cast

Re: [Haskell-cafe] Haskell home page not updated

2007-11-07 Thread Yitzchak Gale
Paul Johnson wrote: The Haskell home page hasn't been updated since 23rd September, even though a Haskell Weekly News came out on October 25th. Not to mention GHC 6.8.1. -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] About Fibonacci again...

2007-11-08 Thread Yitzchak Gale
rabbit = 1 : concatMap ((0:) . flip replicate 1 . (1+)) rabbit This nasty acquaintance of mine... demanded the solution (in Haskell) as a one-liner. It wasn't you yourself, was it? No. Please, tell me it isn't so. Regards, Yitz ___ Haskell-Cafe

Re: [Haskell-cafe] FW: please help... small problem

2007-11-10 Thread Yitzchak Gale
Hi Ryan, You wrote: I've attempted to cut down this module... but I cannot see where... can someone help... You don't need wordToInt - just use read instead. Look at the type of the function map in the Prelude - you can use it to get rid of method and test. After that, your program will be

Re: [Haskell-cafe] Some More Sinus Results

2007-11-10 Thread Yitzchak Gale
Hans van Thiel wrote: If you mean that people should not do arithmetic on computers, if the results are vital, unless they understand the scope and limits of the tools they're using, I agree, of course. My brother used to work for a certain well-known manufacturer of CPUs. He told me that the

Re: [Haskell-cafe] How to do this in Haskell

2007-11-11 Thread Yitzchak Gale
Hi Chris, You wrote: If you wanted to write a Haskell application that included a WYSIWYG HTML editor, how would you do it? I would use fckeditor. Why do you need to write an HTML editor from scratch in Haskell? That is a very, very big wheel to re-invent. Regards, Yitz

Re: [Haskell-cafe] Re: Weird ghci behaviour?

2007-11-14 Thread Yitzchak Gale
I was also bitten by this. I consider it to be a serious problem with the UI for ghci. My vote is: o The default should be to make all symbols available whenever possible. o It should be easy for experts, like Aaron Denney, to get the current behavior. (E.g., a flag, that can be turned on or

Re: [Haskell-cafe] ANN: The Monad.Reader Issue 9: SoC special

2007-11-19 Thread Yitzchak Gale
Wouter Swierstra wrote: I am pleased to announce that a new issue of The Monad.Reader is now available: http://www.haskell.org/haskellwiki/The_Monad.Reader Dougal Stanton wrote: Thanks Wouter, the haiku look great! ;-) I agree, they are fantastic! (And they are not short.) Perhaps you

Re: [Haskell-cafe] Why aren't Float and Double Bounded?

2007-11-27 Thread Yitzchak Gale
Bit Connor wrote: Also, a related question: How do you convert from Float - Double, and the reverse? Only thing I could find is (fromRational . toRational) which I also imagine to be slow, and I also wonder about accuracy. realToFrac -Yitz ___

Re: [Haskell-cafe] A tale of Project Euler

2007-11-27 Thread Yitzchak Gale
Andrew Coppin wrote: On the other hand, I must relay to you how much fun I had with certain other problems. You may want to look at: http://haskell.org/haskellwiki/Euler_problems and make some contributions. But be very careful what you peek at, so don't spoil your own fun. Regards, Yitz

Re: [Haskell-cafe] Re: New slogan for haskell.org

2007-11-29 Thread Yitzchak Gale
lemming wrote: Python page could start with: You like 'map', 'filter', 'for x in ...' and lambda's in Python? Then you will like to learn where Python has What about iterators - lazy lists - and generators - lazy function definitions. And list comprehensions, both lazy and strict. And zip. And

Re: [Haskell-cafe] Progress indications

2007-11-29 Thread Yitzchak Gale
Bit Connor wrote: computation is. And since it's all calls to map and filter et al., it's ...it's not immediately clear how to provide any feedback on how much longer there is to wait. Andrew Coppin wrote: It seems unsafePerformIO is the way to go here. ...unsafeInterleaveIO I disagree. The

Re: [Haskell-cafe] Trees

2007-12-03 Thread Yitzchak Gale
Adrian Neumann wrote: data Tree a = Leaf a | Node a [Tree a] example: given a tree t and two nodes u,v, find the first common ancestor. In Java this is really simple, because each node has a parent reference... In Haskell however the best way I've come up with so far is doing a BFS and

Re: [Haskell-cafe] Why is this strict in its arguments?

2007-12-06 Thread Yitzchak Gale
Jules Bean wrote: I think the 'right' answer for this case is to drop the maybes and just use lists, which is what the OP himself realised. Yes, part of the fun of programming is when you realize that you have been re-implementing the right data type inside of a wrong one. Alistair Bayley

[Haskell-cafe] Re: About -Wall option

2007-12-06 Thread Yitzchak Gale
Luis Cabellos wrote: I have a question, what's the best way to program? - put all the signatures in the Haskell Code? - Only put the type signatures needed to compile (like monomorphism errors or ambiguous signature)? Wolfgang Jeltsch wrote: Inserting all type signatures is definitely best

Re: [Haskell-cafe] class default method proposal

2007-12-12 Thread Yitzchak Gale
Simon Peyton-Jones wrote: Given instance C T where ..., for any method 'm' not defined by ...: for every class D of which C is a superclass where there is an instance for (D T) see if the instance gives a binding for 'm' If this search finds exactly one

Re: [Haskell-cafe] Execution of external command

2007-12-13 Thread Yitzchak Gale
Hi Bulat, You wrote: please help me with selection of proper function to use i need to run external command with parameter and get its stdout, smth like this: output - system cmd param the code should be compatible with unix and windows, and it should be possible to execute scripts (so afaiu

Re: [Haskell-cafe] Execution of external command

2007-12-13 Thread Yitzchak Gale
so, do (stdin,stdout,stderr,ph) - runInteractiveCommand script param waitForProcess ph when i should read stdout? before or after waitForProcess? If you are sure that your script will behave nicely (or don't care if it doesn't), how about just: (_, h, _, _) - runInteractiveCommand script

Re: Re[2]: [Haskell-cafe] Execution of external command

2007-12-13 Thread Yitzchak Gale
Bulat Ziganshin wrote: to Yitzchak: and you've asked what's wrong with runInteractiveCommand? :))) It was a good question. It prompted Duncan to post some really cool stuff, and we all learned something. -Yitz ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Re: Execution of external command

2007-12-13 Thread Yitzchak Gale
Bulat Ziganshin wrote: ...are there any objections against... (_, h, _, _) - runInteractiveCommand script params output - hGetContents h taking into account that bad-behaved scripts are not my headache? bad-behaved scripts are not my headache is not the same as behave nicely. Or I guess

Re: [Haskell-cafe] Re: Execution of external command

2007-12-13 Thread Yitzchak Gale
(_,h,e,_) - runInteractiveCommand script params clearStderr output - hGetContents h where clearStderr is one of: 1. hClose e 2. hGetContents e = evaluate . last 3. forkIO (hGetContents e = evaluate . last return ()) all seem to work for me on Mac OS. Only 2 hangs on Debian testing. What

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-15 Thread Yitzchak Gale
Ah, good old seq. How I loathe it. Seriously, though, good catch. I always forget about seq when I'm doing stuff like this. When using seq and _|_ in the context of categories, keep in mind that Haskell composition (.) is not really composition in the category-theoretic sense, because it adds

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Yitzchak Gale
I wrote: (.!) f g x = f `seq` g `seq` f (g x) Roberto Zunino wrote: id .! undefined == \x - undefined /= undefined Probably you meant (.!) f g = f `seq` g `seq` (f . g) Yes, thank you. -Yitz ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-17 Thread Yitzchak Gale
Derek Elkins wrote: There is another very closely related adjunction that is less often mentioned. ((-)-C)^op -| (-)-C or a - b - C ~ b - a - C This gives rise to the monad, M a = (a - C) - C this is also exactly the comonad it gives rise to (in the op category which ends up being the

Re: [Haskell-cafe] FW: Treating command-line arguments as a Haskell expression

2007-12-24 Thread Yitzchak Gale
Simon Peyton-Jones: Would someone familiar with the command-line-parsing libraries care to help Krassimir? I agree with Max that it looks like the problem is not doing any fancy command-line parsing (if that is indeed the issue, then please post more information about what the problem is).

Re: [Haskell-cafe] Trouble with types

2007-12-25 Thread Yitzchak Gale
Hi Konstantin, Here is yet another possible approach: Perhaps you really meant what you wrote in your definition of firstFunction - namely, that it needs to be polymorphic, so that it can convert to _any_ type that is an instance of SecondClass. In that case, you might want to add another

Re: [Haskell-cafe] Printing and Referential transparency excuse

2007-12-25 Thread Yitzchak Gale
Hi Cristian, Cristian Baboi wrote: While reading the Haskell language report I noticed that function type is not an instance of class Read. I was told that one cannot define them as an instance of class Show without breaking referential transparency or printing a constant... How can I define

Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Yitzchak Gale
Cristian Baboi wrote: http://en.wikipedia.org/wiki/First-class_object I'll guess that 5,9,12 does not apply to Haskell functions. I think there is a basic semantic difference between what the author of that article meant by the word function and what we mean by that word when we are talking

Re: Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Yitzchak Gale
Cristian Baboi wrote: I think I found the answer to why functions cannot be written to files. This is by design. Haskell must be free. Enabling writing functions to files, might make it ilegal in some countries. :-) Ha, excellent! I imagine that is what Haskell must have been like before

Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Yitzchak Gale
Cristian Baboi wrote: Ah! You must have been thinking that function in Haskell are members of DATA types. Or, to put it another way, Haskell make no distinction between data types and function types. Yes. I wrote: Like any type, only certain operations make sense on functions... Yes, but

Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-27 Thread Yitzchak Gale
Wolfgang Jeltsch wrote: If x doesn't equal y, x == y is False, but if x equals y, x == y might be True or undefined. apfelmus wrote: x == y may be _|_ for the False case, too, depending on its implementation (like first comparing all list elements on even indices and then comparing all list

Re: [Haskell-cafe] Basic question concerning data constructors

2008-01-01 Thread Yitzchak Gale
Andrew Bromage wrote: [*] Theoretical nit: It's not technically a set. Consider the data type: data Foo = Foo (Foo - Bool) This declaration states that there's a bijection between the elements of Foo and the elements of 2^Foo, which by Cantor's diagonal theorem cannot be true for any

Re: [Haskell-cafe] Basic question concerning data constructors

2008-01-01 Thread Yitzchak Gale
Andrew Bromage wrote: [*] Theoretical nit: It's not technically a set. Consider the data type: data Foo = Foo (Foo - Bool) This declaration states that there's a bijection between the elements of Foo and the elements of 2^Foo, which by Cantor's diagonal theorem cannot be true for any

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-03 Thread Yitzchak Gale
Hi Jonathan, I wrote: So in what way are Set morphisms restricted from being Hask morphisms? Jonathan Cast wrote: The normal view taken by Haskellers is that the denotations of Haskell types are CPPOs. CPPO? So: (1) Must be monotone (2) Must be continuous Could you please define what

Re: [Haskell-cafe] Basic question concerning data constructors

2008-01-03 Thread Yitzchak Gale
Hi Benja, I wrote: By the type expression Integer - Integer we mean all Haskell functions mapping Integers to Integers. There are only countably many of those. ... But that was not the context in this thread. The category Hask that we often mention in discussions about Haskell the

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-03 Thread Yitzchak Gale
Jonathan Cast wrote: The normal view taken by Haskellers is that the denotations of Haskell types are CPPOs. I wrote: CPPO? (1) Must be monotone (2) Must be continuous Could you please define what you mean by those terms in this context? Jens Blanck wrote: The extra P would stand for

Re: [Haskell-cafe] Consensus about databases / serialization

2008-01-03 Thread Yitzchak Gale
Peter Verswyvelen wrote: Looks good! I liked relational algebra much much more than SQL, so I'll certainly have to look into that. I agree. I have not tried haskelldb yet, but I would like to. My impression from some previous posts is that because of the high-level approach, it is difficult

Re: [Haskell-cafe] Consensus about databases / serialization

2008-01-03 Thread Yitzchak Gale
I wrote: ... to control the precise SQL that is generated. In practice, you almost always have to do some tweaking that is at least DB-dependent, and often application dependent. Peter Verswyvelen wrote: Can't the same be said regarding SQL itself? It sometimes needs tweaking. That's the

Re: [Haskell-cafe] Consensus about databases / serialization

2008-01-03 Thread Yitzchak Gale
Lihn, Steve wrote: For small queries, it does not matter much which approach you choose. But for large, complex queries, such 3-table join (especial Star Transformation) and/or large data set (millions of rows involved in large data warehouses), the performance will differ by order of

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-05 Thread Yitzchak Gale
Jonathan Cast wrote: The normal view taken by Haskellers is that the denotations of Haskell types are CPPOs. So: (1) Must be monotone (2) Must be continuous (Needn't be strict, even though that messes up the resulting category substantially). I wrote: I'm not convinced that the category

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Yitzchak Gale
I wrote: What goes wrong with finite coproducts? The obvious thing to do would be to take the disjoint union of the sets representing the types, identifying the copies of _|_. Jonathan Cast wrote: This isn't a coproduct. If we have f x = 1 and g y = 2, then there should exist a function h

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Yitzchak Gale
(sorry, I hit the send button) What is the lifted version you are referring to? Take the ordinary disjoint union, and then add a new _|_ element, distinct from both existing copies of _|_ (which are still distinct from each other). Now why is that not the category-theoretic coproduct? h .

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Yitzchak Gale
I wrote: ...it was recently claimed on this list that tuples are not products in that category. Derek Elkins wrote: Johnathan has given such a demonstration (and it has been demonstrated many times on this list since it's creation, it's well-known). We're still working on it. I've not been

Re: [Haskell-cafe] US Homeland Security program language security risks

2008-01-09 Thread Yitzchak Gale
Galchin Vasili wrote on Friday, January 4: I stumbled across this page. It seems that Haskell and other strongly typed functional languages like Ml/OCaml will fare much, much better, e.g. buffer overrun. Thoughts . comments. Bulat Ziganshin wrote: for me, it looks like saying that

Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Yitzchak Gale
Mitar wrote: Why is 0/0 (which is NaN) 1 == False and at the same time 0/0 1 == False. This means that 0/0 == 1? No, because also 0/0 == 1 == False. I understand that proper mathematical behavior would be that as 0/0 is mathematically undefined that 0/0 cannot be even compared to 1.

Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Yitzchak Gale
Cristian Baboi wrote: and there is no such thing as the same bottom right ? Yes and no. Semantically, every bottom is the same. However, the Haskell Report makes bottom an explicit exceptional case. Compilers are allowed to do whatever they want with bottoms, including different results for

Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Yitzchak Gale
Cristian Baboi wrote: and there is no such thing as the same bottom right ? I wrote: Yes and no. Semantically, Yes and No is bottom ? Yes and no. -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Yitzchak Gale
Cristian Baboi wrote: I think this should be put this way: Bottom is a part of the semantic domain which is not Haskell. Rather, something outside Haskell that describes what Haskell programs mean. Yes. In the semantic domain there is one bottom. In Haskell there are many expressions that

Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Yitzchak Gale
I wrote: Like nearly all programming languages, Haskell implements the standard IEEE behavior for floating point numbers. That leads to some mathematical infelicities that are especially irking to us in Haskell, but the consensus was that it is best to follow the standard. Jules Bean wrote:

Re: [Haskell-cafe] Re: search Data.Tree.Zipper

2010-03-09 Thread Yitzchak Gale
Jian Fan wrote: I somehow cannot figure this out. Tree is Foldable so I can use find on it. But how can I use find on TreeLoc? Am I missing something obvious? But what exactly is a TreeLoc? Hoogle doesn't know about it. If you created it yourself, you haven't showed us how you defined it or

Re: [Haskell-cafe] Num instance for Lazy ByteStrings (was: NumLazyByteString Package License)

2010-03-09 Thread Yitzchak Gale
Henning Thielemann wrote: Is NumLazyByteString a newtype around Bytestring.Lazy that interprets the bit stream represented by the ByteString as integer? Thomas DuBuisson wrote: Not exactly.  There is not newtype wrapper.  NumLazyByteString is: instance Num L.ByteString where  ... Are you

Re: [Haskell-cafe] Mini-announce: AC-Color 1.1.3

2010-03-09 Thread Yitzchak Gale
Andrew Coppin wrote: I just uploaded a new version of the AC-Colour package... Thanks for this. Your algorithm for scaling brightness is not correct however. The RGB values in all popular image formats are not linear. They use a gamma transfer function. So your algorithm will indeed change the

Re: [Haskell-cafe] Re: search Data.Tree.Zipper

2010-03-09 Thread Yitzchak Gale
Jian Fan wrote: Following is what I have for now... Oh, nice! That is simpler. Now we can do: searchTree pred rootLoc | pred (getLabel rootLoc) = Just rootLoc | otherwise = search right `mplus` search firstChild where search next = next rootLoc = searchTree pred Regards,

Re: [Haskell-cafe] definition of sum

2010-03-11 Thread Yitzchak Gale
TeXitoi wrote: why is foldl used by Data.List for sum? Daniel Fischer wrote: Because Haskell is a non-strict language, and foldl' is strict -- someone might write a (legitimate) Num instance for a datatype such that foldl (+) 0 xs returns a good value, but foldl' (+) 0 xs gives ***Exception:

Re: [Haskell-cafe] definition of sum

2010-03-14 Thread Yitzchak Gale
Daniel Fischer wrote: I'm not sure whether it's a wart or a bug, but I agree that it would be better to have the default sum strict David Leimbach wrote: That would be really inconsistent with the way the rest of the Haskell language and libraries works... I would propose that... sum be

Re: [Haskell-cafe] th-kinds v0.0.0

2010-03-17 Thread Yitzchak Gale
Louis Wasserman wrote: I just released a package, th-kinds, which attempts to automatically infer the kind of a specified type, type constructor, type family, type class, or pretty much anything else that has a kind... It rolls its own kind inference... Interesting. The right way to do this

Re: [Haskell-cafe] Syntax programming with lexemes rather than trees?

2010-03-24 Thread Yitzchak Gale
Stephen Tetley wrote: LilyPond has already answer this one... trying for a typed representation would be too restrictive - LilyPond has a very large LaTeX style syntax for assembling scores. I find LilyPond's very monolithic very stateful representation to be ugly and awkward. It clearly

  1   2   3   4   5   6   >