Re: [Haskell-cafe] Proposal: Applicative = Monad: Call for consensus
uj supplied this: About the discussion putStrLn (readLn + (5 :: Int)).. I'll write it as the following line, importing Control.Applicative main = (+) readLn (return 3) They look almost exactly same in my eyes.. On Fri, 21 Jan 2011 11:01:36 -0800, you wrote: Interesting little paper, Tyson. You bring up other programming languages and 'ad-hoc systems for resolving ambiguities'; I agree with you that these systems generally have no strong theoretical basis, but I'm not sure that's a terribly bad thing. I think what a programmer actually wants from ambiguity resolution is something *predictable*; C++'s system is definitely stretching the boundaries of predictability, but any case where I have to break out a calculator to decide whether the compiler is going to choose specification A or specification B for my program seems like a failure. I'd much rather the solution wasn't always 'the most probable' but at least was easy for me to figure out without thinking too hard. The goal is to easily know when I have to manually specify ambiguity resolution and when I can trust the compiler to do it for me. I didn't completely follow the math in your paper, so maybe it turns out simply if it was implemented, but it wasn't clear to me. At the least, I think you should add examples of the types of ambiguity resolution you'd like the compiler to figure out and what your probability measure chooses as the correct answer in each case. Anyways, thanks for the interesting read. I'm excited to see work on making a better type *inference* system, since much of the work lately seems to be on making a better *type* system at the cost of more often manually specifying types. I work in a traditional programming industry, and most of the people from work that I talk to about Haskell are frustrated that they can't just write putStrLn (readLn + (5 :: Int)) and have the compiler figure out where the lifts and joins go. After all, that just works in C[1]! What's the point of having the most powerful type system in the universe if the compiler can't use it to make your life easier? -- ryan [1] sample program: int readLn(); // reads a line from stdin and converts string to int void putStrLn(int x); // prints an int to stdout void main() { putStrLn(readLn() + 5); } On Fri, Jan 21, 2011 at 8:43 AM, Tyson Whitehead twhiteh...@gmail.com wrote: On January 19, 2011 15:28:33 Conor McBride wrote: In each case, the former has (++) acting on lists of strings as pure values, while the latter has (++) acting on strings as values given in []-computations. The type [String] determines a domain, it does not decompose uniquely to a notion of computation and a notion of value. We currently resolve this ambiguity by using one syntax for pure computations with [String] values and a different syntax for [] computations with String values. Just as we use newtypes to put a different spin on types which are denotationally the same, it might be worth considering a clearer (but renegotiable) separation of the computation and value aspects of types, in order to allow a syntax in which functions are typed as if they act on *values*, but lifted to whatever notion of computation is ambient. Yes. ?That makes sense. ?Thank you both for the clarification. ?The idea of explicitly separating the two aspects of types is an interesting one. The automated approach I had been thinking of was to always take the simplest context possible. ?(i.e., for the above, list of strings as pure values). To this end I've been working on a measure for the complexity of the application operator. ?I've got a draft at http://www.sharcnet.ca/~tyson/haskell/papers/TypeShape.pdf I'm still working on my thinking on polymorphic types though, so everything from section 2.2 onwards is subject to change (especially 2.3 and the conclusion). Cheers! ?-Tyson ___ 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 -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell in Industry
Of course Banks/Financial Firms/Investment Banks want software that is correct, secure, and logs transactions. Aspects are great for cross-cutting concerns like security and logging; as in AspectJ. For correctness, functional programming has that. With monads its easy to add logging and security. Something the BCLC (British Columbia Lottery Corporation) has missed entirely. :) On Tue, 10 Aug 2010 14:05:50 +0800, you wrote: Remember that Banks/Financial Firms/Investment Banks were among the first big uses of punch card readers, mainframes, cobol, C, C++ (and OOP), VBA, Java.. I'm not saying if I like any of those languages (my presence on this list should give a clue how I feel) but investment banks picking up FP and Haskell bodes quite well for Haskell in the future. Max On Aug 10, 2010, at 12:59 AM, Tom Hawkins wrote: Good, we need more functional programmers actually solving real problems. But please put your skills to work in an industry other than investment banking. I've received a lot mail on this comment; mostly positive. Here's one from someone who wishes to remain anonymous: First of all I would like to say that I like your work regarding e.g. Atom. Second, I would like to know what exactly is bad about a Haskell job in investment banking as a lot of good programmers work in this industry. It's disproportionate. 95% of the job offerings in functional programming are with investment firms. I believe investment banking is important, but does it really need to dominate a large percentage of the world's top tier programmers? Is computing the risk of derivative contracts more important than pursuing sustainable energy, new drug discovery, improving crop yields, etc. Some will argue investment banking enables all of these things -- and I'm sure many people in the industry go to work everyday feeling proud of their contributions. But I just think most of this talent is going in to improve the bottom line and little else. (Yes, I realize that's were the money is, and that's who's hiring. Actually I'm very glad. Investment banking is the first industry to adopt functional programming on a large scale. And others will follow.) -Tom -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Multidimensional Matrices in Haskell
Doesn't mutable state have to be held in a monad? If you want mutable like behaviour without a monad, you may want a tree or some other data structure. On Wed, 7 Jul 2010 17:08:48 +0300, you wrote: Hi, A friend of mine wanted to do some Cellular Automata experiments in Haskell and was asking me what packages/libraries are there for multidimensional matrices. I'm interested in both immutable and mutable ones but I don't want them to be trapped inside a monad of any kind. Any hints? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is there good place to post Haskell alorithms/data structures that follow Steven Skiena's book on algorithm design and also Haskell code snippets that follow some of Knuth's books?
Is there good place to post Haskell alorithms/data structures that follow Steven Skiena's book on algorithm design and also Haskell code snippets that follow some of Knuth's books? These code snippets don't seem to fit with Hackage. Is there a Hatorial? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
But as a starting point, and especially to shake up preconceived notions, it still helps to compress common prejudices this way. Many people think they are thinking when they are merely rearranging their prejudices. William James? :) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
I remember quite a few months ago, someone gave a presentation on Haskell and he admitted that so far all he had used it for were shell scripts. He said that his Haskell shell scripts ran faster than his shell scripts written in ? So all he had used so far, was just the imperative part of Haskell. On Wed, 16 Jun 2010 00:06:54 UTC, Marc Weber marco-owe...@gmx.de wrote: Hi Aditya Siram, - maybe shell scripting: running ghci takes longer than starting bash. Compiling is not always an option because executables are bigger than shell scripts or C executables snip Marc Weber -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Steven S. Skiena of The Algorithm Design Manual, Second Edition, 2008 has sent me a message that if there is a Haskell page of algorithms he will link to it.
I have both books. The challenge is to get something linked from the The Stony Brook Algorithm Repository (http://www.cs.sunysb.edu/~algorith/) to a Haskell algorithms/data structures page to promote Haskell. For those who would not pick up a book (nor web page) with Haskell or functional in the title. Even for those who would not pick up a book (nor web page) with algorithms or data structures in the title. Hm! That last group might be plants and plants should be studying botany, anyway. On Fri, 28 May 2010 09:49:53 -0500, you wrote: On Fri, May 28, 2010 at 4:45 AM, Chris Eidhof ch...@eidhof.nl wrote: Nhe most important reference in literature might be Okasaki's Purely functional data structures: @book{okasaki1999purely, ?title={{Purely functional data structures}}, ?author={Okasaki, C.}, ?year={1999}, ?publisher={Cambridge Univ Pr} } -chris Although not exactly a page as requested, Okasaki's thesis is available online and there is an implementation in Haskell of his data structures: http://hackage.haskell.org/package/EdisonCore Another book on functional algorithms, but using Haskell: http://www.iro.umontreal.ca/~lapalme/Algorithms-functional.html @book{rabhi1999algorithms, title={{Algorithms; A Functional Programming Approach}}, author={Rabhi, F. and Lapalme, G.}, year={1999}, publisher={Addison-Wesley Longman Publishing Co., Inc. Boston, MA, USA} } A few other links: http://www.haskell.org/haskellwiki/Applications_and_libraries/Data_structures http://en.wikibooks.org/wiki/Haskell -- see Haskell Performance Take care, Paulo -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Steven S. Skiena of The Algorithm Design Manual, Second Edition, 2008 has sent me a message that if there is a Haskell page of algorithms he will link to it.
Hi: Steven S. Skiena of The Algorithm Design Manual, Second Edition, 2008 has sent me a message that if there is a Haskell page of algorithms he will link to it. So, is there such a page and/or is there some collection(s) of algorithms and data structures some where that I can massage into the shape of his book? :) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Math questions
This is an effect with any language that offers a very high degree of abstraction. I think this is an example of the Haskell effect (more typically seen on #haskell), which can be categorised as follows: 1) Someone asks a (usually rather simple) question. 2) People discuss this and provide several straightforward and relevant answers. 3) Out of curiosity (and probably a fair dose of masochism) others then start to golf the solution into the most interesting approach possible. 4) The person that asked the question initially gets lost (but is quite often awed at all the amazing stuff that's going on around them zooming past at light speed). 5) People suddenly remember that there was an initial question and make an attempt to explain the more advanced solutions to the person that asked the question in the first place. 6) They smile and nod and pretend they understand whilst putting a note onto their copious TODO list to someday sit down and try to work out wtf was going on. 7) ??? 8) Profit!!! -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Apparently, Erlang does not have a static type system, since with hot code loading, this is intrinsically difficult.
Apparently, Erlang does not have a static type system, since with hot code loading, this is intrinsically difficult. Erlang Programming, Francesco Cesarini Simon Thompson, June 2009, O'Reilly, page 31. If Haskell allows hot code loading, would this throw a wrench into the static type system? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bubble sort algorithm implementations (Haskell vs. C)
You may want to use a mutable array. The performance may suffer from the memory allocation for the list. I wonder if it's possible to make Haskell implementation work faster without changing the algorithm (there's are actually a few tricks to make it work faster, but neither implementations have these optimizations). I'm interested not in particular algorithm performance but rather in performance of its implementations in various languages. I compiled the Haskell implementation in GHC (Haskell Platform 2009.2.0.2), which is the latest available from the site. If you are interested in its performance in various languages you may want to implement the Bubble Sort the best way in each language. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to do the permutation and combination thing?
This sounds like homework. Think in abstract terms what you want to accomplish. Start with the simplest case first, usually the base case. On Fri, 12 Mar 2010 14:02:02 +0800, you wrote: Hi, For example, I have this: list1 = [a, b, c] list2 = [d, e, f] list3 = [g, h, i] Now I want: [ [(a, d, g), (b, e, h), (c, f, i)] , ... ] -- a list that contains all the combinations. How to do it pretty? Thanks. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to detect duplicates
On Tue, 23 Feb 2010 08:30:18 -0300, you wrote: Hi folks, While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. Must it be a list data structure(DS) or list ADT? Mergesort can be parallelized. Best regards, Rafael -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to detect duplicates
On Tue, 23 Feb 2010 08:30:18 -0300, you wrote: Hi folks, While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. Must it be a list data structure(DS) or list ADT? Mergesort can be parallelized. Best regards, Rafael If space is at a premium you might want to look at a Bloom Filter. http://en.wikipedia.org/wiki/Bloom_filter The Bloom filter, conceived by Burton Howard Bloom in 1970,[1] is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positives are possible, but false negatives are not. Elements can be added to the set, but not removed (though this can be addressed with a counting filter). The more elements that are added to the set, the larger the probability of false positives. The book Real World Haskell has an implementation. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism?
On Tue, 9 Feb 2010 21:56:49 +, you wrote: Monads are not commutative. A structure that would tell the compiler that it's commutative, would give it more leeway for optimization (and parallel execution). Thank you. Not commutative was the phrase I was looking for. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack ADT?
You could also implement stacks with mutable data structures, e.g. STArray, etc. What do you want to use a stack ADT for? Usually stacks are discussed for pedagogical purposes but usually recursion is used if you need a stack like operation. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack ADT?
On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote: Can't find a Stack datatype on Hoogle? Where should I look? Michael From Algorithms: a functional programming approach Second edition Fethi Rabhi Guy Lapalme data Stack a= EmptyStk | Stk a (Stack a) push x s= Stk x s pop EmptyStk= error pop from an empty stack pop (Stk _ s) = s top EmptyStk= error top from an empty stack top (Stk x _) = x emptyStack = EmptyStk stackEmpty EmptyStk = True stackEmpty _= False newtype Stack a = Stk [a] push x (Stk xs) = Stk (x:xs) pop (Stk [])= error pop from an empty stack pop (Stk (_:xs))= Stk xs top (Stk [])= error top from an empty stack top (Stk (x:_)) = x emptyStack = Stk [] stackEmpty (Stk []) = True stackEmpty (Stk _ ) = False -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack ADT?
On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote: Can't find a Stack datatype on Hoogle? Where should I look? Michael From Algorithms: a functional programming approach Second edition Fethi Rabhi Guy Lapalme To be more complete. module Stack(Stack,push,pop,top,emptyStack,stackEmpty) where push:: a- Stack a - Stack a pop :: Stack a - Stack a top :: Stack a - a emptyStack :: Stack a stackEmpty :: Stack a - Bool data Stack a= EmptyStk | Stk a (Stack a) push x s= Stk x s pop EmptyStk= error pop from an empty stack pop (Stk _ s) = s top EmptyStk= error top from an empty stack top (Stk x _) = x emptyStack = EmptyStk stackEmpty EmptyStk = True stackEmpty _= False newtype Stack a = Stk [a] push x (Stk xs) = Stk (x:xs) pop (Stk [])= error pop from an empty stack pop (Stk (_:xs))= Stk xs top (Stk [])= error top from an empty stack top (Stk (x:_)) = x emptyStack = Stk [] stackEmpty (Stk []) = True stackEmpty (Stk _ ) = False -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Why?
I have not read all/most of the replies. What material benefit does Haskell derive from being a pure functional language as opposed to an impure one? Please provide examples as I require instruction. A pure functional lanugage allows lazy evaluation, which adds another tool to your modularity toolbox, since it separates control from computation. In a pure functional language state is very carefully isolated from the rest of your program. This makes all sorts of optimizations trivial that are very hard to do in other languages. Optimizations are done in code algebra, which is very easy to do in Haskell (for pure functions), for example optimizations are harder to do in the code algebra of Java. For a better discussion of code algbra please see the following book: Practical Formal Software Engineering: Wanting the Software You Get Bruce Mills, 2009 -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Are there major inefficiencies in Haskell compared to OCaml?
Are there major inefficiencies in Haskell compared to OCaml? If so, can something be done about them? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] seems like I'm on the wrong track
Please check out Paul Hudak's page. http://cs-www.cs.yale.edu/homes/hudak-paul/ On Tue, 01 Dec 2009 17:01:29 -0800, you wrote: Perhaps someone could either (1) help me do what I'm trying to do, or (2) show me a better way. I have a problem that is very state-ful and I keep thinking of it as OO, which is driving me crazy. Haskell is several times harder to use than Python in this instance, probably because I'm doing it wrong. To give you a larger context, this problem is essentially compiling a description of music (my own) into a kind of music-machine-language (CSound). CSound is relatively untidy. In this one example, in a OO way of thinking, I have data called AssignedNumbers that assigns integers to unique strings and keeps track of the used integers and next available integer (the choice of available integer could follow a number of conventions so I wanted to hide that in an ADT.) So it has an associated function: getNumber :: String - AssignedNumbers - (Int,AssignedNumbers) What getNumber does is: - check if the string already has a number assigned to it. If so, return that number. - if not, pick the next available number. - in all cases, return the possibly changed state of AssignedNumbers Then in a larger data structure, it contains fields of type AssignedNumbers. Like data MusicStuff = MusicStuff { oscillatorNumbers :: AssignedNumbers , tableNumbers :: AssignedNumbers , ... } I'm using MusicStuff in a State monad, so I might write a function like doSomeMusicStuff :: String - String - State MusicStuff (Int,Int) doSomeMusicStuff aString1 aString2 = do ms - get (o1,newOscNums) = getNumber aString1 (oscillatorNumbers ms) (t1,newTabNums) = getNumber aString2 (tableNumbers ms) put ms { oscillatorNumbers = newOscNums , tableNumbers = newTabNums } return (o1,t1) For what it does, this is extremely verbose and filled with distracting visual content. And this is just a very simple example---my real problem is several times more state-ful. Is there a better way? Note that in Python it would be a method def doMusicStuff( self, s1, s2 ) : return (self.oscillatorNumbers.next(s1), self.oscillatorNumbers.next(s2)) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Tips for a FFI-wrapped C library?
I would suspect that the IO Monad is to unsafe, maybe a more stringent monad would be more appropriate. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Partially applied functions
You can pattern match on the right hand side of '|' in a list comprehension, since a list comprehension is just the list monad. Just changed a few things. Hopefully this answers the OP's question and any interested others. add :: Int - Int - Int add x y = x + y -- a list of partially applied functions adds = [add 3, add 5, add 7, add 3, add 5, add 8] -- an example usage of the list kP pred = map (\ f - f 10 ) (addPs pred) -- Wanted to do things like this. -- add3s = filter (?) adds -- add3s = [add 3, add 3] -- addEvens = filter (?) adds --addEvens = [add 8] -- addPs num = [ x | x - adds, x 0 == num ] -- Changed 'x' to 'f' indicating a function application. addPs pred = [ f | f - adds, pred (f 0) ] -- Main kP (==3) -- Main kP even -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Partially applied functions
Will the following do what you wish? add :: Int - Int - Int add x y = x + y addends = [3,5,7,3,5,8]::[Int] add3s :: [Int] - [Int - Int] add3s addends = map add (filter (3==) addends) k3 :: [Int] k3 = map (\ f - f 10 ) (add3s addends) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Partially applied functions
Will the following do what you wish? add :: Int - Int - Int add x y = x + y addends = [3,5,7,3,5,8]::[Int] -- P for predicate addPs :: (Int - Bool) - [Int] - [Int - Int] addPs predicate addends = map add (filter predicate addends) kP :: [Int] kP = map (\ f - f 10 ) (addPs (3==) addends) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Partially applied functions
It sounds as if you want to carry some state around for each partially applied function, I think that's in monad territory. A cardinal rule of functional programming is to create new data, whenever possible. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Partially applied functions
You can pattern match on the right hand side of '|' in a list comprehension, since a list comprehension is just the list monad. add :: Int - Int - Int add x y = x + y -- a list of partially applied functions adds = [add 3, add 5, add 7, add 3, add 5, add 8] -- an example usage of the list kP num = map (\ f - f 10 ) (addPs num) -- add3s = filter (?) adds -- add3s = [add 3, add 3] -- addEvens = filter (?) adds --addEvens = [add 8] addPs num = [ x | x - adds, x 0 == num ] -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Reducing Latency - Reducing the Size of Larger Data Structures
An idea to reduce memeory latency, is to have a complex dual/quad/etc. core CPU surrounded by four or more simpler CPUs. The simpler CPUs have a simpler instruction set and do less context switching. So any operations (e.g. folding, filtering) that reduce the size of a larger data structure and that can be done on the simpler CPU instruction sets are shunted off to the simpler CPUs. So, the complex CPUs receive less data and therefore can have better cacheing performance, less latency and better throughput. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. Bitwise Tricks Techniques
If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. The Art of Computer Programming: Volume 4 Bitwise Tricks Techniques Binary Decision Diagrams Fascicle 1 Donald E. Knuth 2009 Describes basic broadword operations and an important class of data structures that can make computer programs run dozens - even thousands - of times faster. I started a Haskell program using bitwise operations and then discarded them thinking them to low level. I think one of the dangers of Haskell, is that I get carried away with medium and high level abstractions and think everything MUST be done that way. :) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. Bitwise Tricks Techniques
Thank you for the URL. On Wed, 18 Nov 2009 18:30:31 -0500, you wrote: I can't compare it with Knuth's fascicle, but the FXT book (linked to from http://www.jjj.de/fxt/) has a whole chapter on bit wizardry and is another excellent resource along these lines. On Wed, Nov 18, 2009 at 6:22 PM, Casey Hawthorne cas...@istar.ca wrote: If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. The Art of Computer Programming: Volume 4 Bitwise Tricks Techniques Binary Decision Diagrams Fascicle 1 Donald E. Knuth 2009 Describes basic broadword operations and an important class of data structures that can make computer programs run dozens - even thousands - of times faster. I started a Haskell program using bitwise operations and then discarded them thinking them to low level. I think one of the dangers of Haskell, is that I get carried away with medium and high level abstractions and think everything MUST be done that way. :) -- Regards, Casey ___ 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 -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Howto start a bigger project
What is this big project about? Why not use www.sourceforge.net? On Mon, 16 Nov 2009 21:15:44 +0100, you wrote: Hi all, I'm stuck with a problem where I need serious help from other haskellers, in particular those that participate here on this list. It's a rather big project and I will need to set it up in an organized way, something with a blog, web page or other means. I tried to solve it by myself while asking the occasional question here but that turned out to be ineefective. The problem as such is certainly of interest for just about any programmer who is using Haskell for real world programming too. In short, to get started I'd appreciate some tips how to set this up. Günther -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] Howto start a bigger project
On Mon, 16 Nov 2009 23:43:49 +0300, you wrote: Hello Casey, Monday, November 16, 2009, 11:30:51 PM, you wrote: Why not use www.sourceforge.net? i strongly recommend http://code.google.com or http://codeplex.com SF is slow and olf-fashioned Just because a Scandinavian started it, doesn't mean its ___-fashioned, somehow! :) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] I'm also missing examples of library function and Hackage usage. Haskell Wiki?
I'm also missing examples of library function and Hackage usage. Where does one put up code on the Haskell Wiki? :) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Where is a good place to place code like this, so if I may be so bold, people can learn from it?
Where is a good place to place code like this, so if I may be so bold, people can learn from it? {- Author Modifications:Casey Hawthorne Author Original: Jeff Newbern Maintainer: Casey Hawthorne cas...@istar.ca Maintainer?: Jeff Newbern jnewb...@nomaware.com Time-stamp: Jeff Tue Aug 19 09:31:32 2003 Time-stamp: Casey Sat Nov 14 10:10 2009 License:GPL The N-queens puzzle is to place N queens on an N by N chess board so that no queen can attack another one. Compiler Flags: ghc -O2 -fvia-c --make N-Queens.hs Description http://www.haskell.org/all_about_monads/html/stacking.html#example Original Code http://www.haskell.org/all_about_monads/examples/example25.hs -} {- Description Example 25 - Using the StateT monad transformer with the List monad to achieve non-deterministic stateful computations, and the Writer monad to do logging Usage: Compile the code and run it with an argument between 1 and 8. It will print a solution to the N-queens puzzle along with a log of the number of choices it had at each step. The N-queens puzzle is to place N queens on a chess board so that no queen can attack another one. The original version always used an 8x8 board. Try: ./ex25 8 ./ex25 1 ./ex25 7 Added by Casey: - different board sizes -- up to a maximum 26x26 square board - updated imports list -} import IO import System import Monad import Data.Maybe import Data.List import Data.Char (toLower) import Control.Monad.State import Control.Monad.Writer -- describe Chess Units and positions type Rank = Int data File = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | X | Y | Z deriving (Eq, Show, Ord, Enum) data Position = Pos {file::File, rank::Rank} deriving Eq instance Show Position where show (Pos f r) = (map toLower (show f)) ++ (show r) instance Ord Position where compare p1 p2 = case (rank p1) `compare` (rank p2) of LT - GT GT - LT _ - (file p1) `compare` (file p2) data Kind = Pawn | Knight | Bishop | Rook | Queen | King deriving (Eq, Ord, Enum) instance Show Kind where show Pawn = P show Knight = N show Bishop = B show Rook = R show Queen = Q show King = K data Color = Black | White deriving (Eq, Ord, Enum) instance Show Color where show Black = b show White = w data Unit = Unit {color::Color, kind::Kind} deriving (Eq, Ord) instance Show Unit where show (Unit c k) = ((show c) ++ (show k)) data Board = Board {size::Int, psns::[(Unit,Position)]} -- newtype Board = Board [(Unit,Position)] -- newtype BoardMax = BoardMax Int instance Show Board where show (Board n ps) = let ordered = (sort . swap) ps ranks = map (showRank ordered) [n,(n-1)..1] board = intersperse (concat (take n (repeat --+))) ranks rlabels = intersperse(map (\n-(twoSpaces n)++ ) [n,(n-1)..1]) flabels = take (n*3) a b c d e f g h i j k l m n o p q r s t u v w x y z twoSpaces n | length (show n) == 2 = show n | otherwise = ++ (show n) in unlines $ zipWith (++) rlabels board ++ [flabels] where swap = map (\(a,b)-(b,a)) showRank ps r =let rnk = filter (\(p,_)-(rank p)==r) ps cs = map (showUnit rnk) (take n [A .. Z]) in concat (intersperse | cs) showUnit ps f = maybe(show . snd) (find (\(p,_)-(file p)==f) ps) data Diagonal = Ascending Position | Descending Position deriving (Eq, Show) -- define the diagonal according to its interesction with rank 1 or size of board) -- or with file a normalize :: Int - Diagonal - Diagonal normalize n d@(Ascending psn) | (rank psn) == 1 = d | (file psn) == A = d | otherwise = normalize n (Ascending (Pos (pred (file psn)) ((rank psn)-1))) normalize n d@(Descending psn) | (rank psn) == n = d | (file psn) == A = d | otherwise = normalize n (Descending (Pos (pred (file psn)) ((rank psn)+1))) -- get the diagonals corresponding to a location on the board getDiags :: Int - Position - (Diagonal,Diagonal) getDiags n p = (normalize n (Ascending p), normalize n (Descending p)) -- this is the type of our problem description data NQueensProblem = NQP {board::Board, ranks::[Rank], files::[File], asc::[Diagonal], desc::[Diagonal]} -- initial state = empty board, all ranks, files, and diagonals free
Re: [Haskell-cafe] Where is a good place to place code like this, so if I may be so bold, people can learn from it?
Hi Bulat: I believe Jeff's original idea was to show an example of a monad transformer stack and ASCII art output. On Sat, 14 Nov 2009 21:42:01 +0300, you wrote: Hello Casey, Saturday, November 14, 2009, 9:15:51 PM, you wrote: Where is a good place to place code like this, so if I may be so bold, people can learn from it? the solution i've seen in 80's was: main = print (solutions 8 8) solutions n 0 = [[]] solutions n k = [(i,k):xs | xs - solutions n (k-1), i - [1..n], check i k xs] check i k xs = and [i1/=i k1/=k abs(i1-i)/=abs(k1-k) | (i1,k1) - xs] -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for a good algorithm
Sorry, I forgot to ask an important question. Is the table stored in a dense format as in complete rows and complete columns or in a sparse table format? The question is more about algorithm than Haskell. But I am going to code in Haskell which I am still learning. Suppose I have a large table, with hundreds of columns and thousands of rows. But not every cell has a value (of String, or Int, or Double type). I want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number, given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. Can someone provide a good algorithm for this problem? (I do not have any background in algorithms.) You can assume I already know which columns are of Int or Double type. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Pattern Matching
Thank you to all who replied, very instructive. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for a good algorithm
To: Casey Hawthorne cas...@istar.ca Subject: Re: [Haskell-cafe] looking for a good algorithm From: Casey Hawthorne cas...@istar.ca Date: Thu, 12 Nov 2009 11:14:02 -0800 On third thought, convert the table to a 2D array of bits (or a 1D array of bits mapped to a 2D coordinate system). The bit is true for either an Int or Double. If space is a concern and one can tolerate a low rate of false positives, than a 2D Bloom Filter might be appropriate, or a 1D Bloom Filter with mapping to 2D coordinates. http://en.wikipedia.org/wiki/Bloom_filter Then on to simmulated annealing, possibly. Note: Donald Knuth's new fascicle is out: Volume 4 Fascicle 1, Bitwise Tricks Techniques; Binary Decision Diagrams (2009), xiii+261pp. ISBN 0-321-58050-8 On Wed, 11 Nov 2009 15:32:35 -0800, you wrote: So, as I understand it, you have a very large sparse table, thousands of rows and hundreds of columns, of which each cell within a column of type String, Int, or Double can contain one of those types or nothing. Then you to want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number (Int or Double), given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. I'm wondering about hashing on the rows and hashing on the columns, then the column hash has the number of Int's or Double's (don't need the String's) in that column and the rows they are in. The row hash would have the number of Int's and Double's in that row and what column's they are in. Then; Then scan the row hash and sort into descending order, and by tagging those rows, not by actually moving them. Then I think your ready for simmulated annealing. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Why can I run (runghc) some Haskell scripts but I cannot seem to compile them?
Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? e.g. http://www.haskell.org/all_about_monads/examples/example25.hs I've changed the import listing to the following: import IO import System import Monad import Data.Maybe import Data.List import Data.Char (toLower) import Control.Monad.State import Control.Monad.Writer -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Why can I run (runghc) some Haskell scripts but I cannot seem to compile them?
Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? e.g. http://www.haskell.org/all_about_monads/examples/example25.hs I've changed the import listing to the following: import IO import System import Monad import Data.Maybe import Data.List import Data.Char (toLower) import Control.Monad.State import Control.Monad.Writer The compiler errors are like the following: N-Queens.o:fake:(.text+0x2fe): undefined reference to `mtlzm1zi1zi0zi2_Controlzi MonadziStateziLazzy_zdf9_closure' N-Queens.o:fake:(.text+0x422): undefined reference to `mtlzm1zi1zi0zi2_Controlzi MonadziStateziLazzy_zdf7_closure' N-Queens.o:fake:(.text+0x66f6): undefined reference to `mtlzm1zi1zi0zi2_Controlz iMonadziWriterziLazzy_zdf1_closure' -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why can I run (runghc) some Haskell scripts but I cannot seem to compile them?
Shazam! Thank you! On Thu, 12 Nov 2009 15:13:47 -0500, you wrote: Did you try ghc --make? On Thu, Nov 12, 2009 at 3:12 PM, Casey Hawthorne cas...@istar.ca wrote: Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? e.g. http://www.haskell.org/all_about_monads/examples/example25.hs I've changed the import listing to the following: import IO import System import Monad import Data.Maybe import Data.List import Data.Char (toLower) import Control.Monad.State import Control.Monad.Writer The compiler errors are like the following: N-Queens.o:fake:(.text+0x2fe): undefined reference to `mtlzm1zi1zi0zi2_Controlzi MonadziStateziLazzy_zdf9_closure' N-Queens.o:fake:(.text+0x422): undefined reference to `mtlzm1zi1zi0zi2_Controlzi MonadziStateziLazzy_zdf7_closure' N-Queens.o:fake:(.text+0x66f6): undefined reference to `mtlzm1zi1zi0zi2_Controlz iMonadziWriterziLazzy_zdf1_closure' -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Pattern Matching
Why in a pattern match like score (1 3) = 7 can I not have sizeMax = 3 score (1 sizeMax) = 7 -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for a good algorithm
So, as I understand it, you have a very large sparse table, thousands of rows and hundreds of columns, of which each cell within a column of type String, Int, or Double can contain one of those types or nothing. Then you to want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number (Int or Double), given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. I'm wondering about hashing on the rows and hashing on the columns, then the column hash has the number of Int's or Double's (don't need the String's) in that column and the rows they are in. The row hash would have the number of Int's and Double's in that row and what column's they are in. Then; Then scan the row hash and sort into descending order, and by tagging those rows, not by actually moving them. Then I think your ready for simmulated annealing. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Area from [(x,y)] using foldl
How about these type signatures. import Data.List poly1 = [(0,1),(5,0),(3,4)]::[(Double,Double)] areaPoly :: [(Double,Double)] - Double areaPolyCalc :: (Double,(Double,Double)) - (Double,Double) - (Double,(Double,Double)) Spoiler Alert! -- Functions Below! areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Area from [(x,y)] using foldl
How about these BETTER type signatures. -- Area of a Polygon import Data.List type X = Double type Y = Double type Area = Double poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)] areaPoly :: [(X,Y)] - Area areaPolyCalc :: (Area,(X,Y)) - (X,Y) - (Area,(X,Y)) Spoiler Alert! -- Functions Below! areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Area from [(x,y)] using foldl
Sorry, I forgot to add that if the polygon is very far from the origin, you may have overflow or increased round off error; it is better to translate the polygon back to the origin, before doing the area calculation. How about these BETTER type signatures. -- Area of a Polygon import Data.List type X = Double type Y = Double type Area = Double poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)] areaPoly :: [(X,Y)] - Area areaPolyCalc :: (Area,(X,Y)) - (X,Y) - (Area,(X,Y)) Spoiler Alert! -- Functions Below! areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Area from [(x,y)] using foldl
On Sun, 8 Nov 2009 15:07:45 -0800 (PST), you wrote: Hi Casey, I was already aware of the translation thing, but didn't want to complicate. Lot's of ways to skin a cat. I wrote a Lispy solution, then had the feeling I could improve on it w/Haskell. Picking the right tool takes practice. Thanks, Michael Since Haskell is a pure functional language, it adds lazy evaluation as another tool to your modularity toolbox. Lazy evaluation separates control from computation, so, if the computation of sum is going off the rails (and I don't mean Ruby on Rails), one can prematurely terminate the calculation, without evaluating more points. --- On Sun, 11/8/09, Casey Hawthorne cas...@istar.ca wrote: From: Casey Hawthorne cas...@istar.ca Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl To: haskell-cafe@haskell.org Date: Sunday, November 8, 2009, 5:44 PM Sorry, I forgot to add that if the polygon is very far from the origin, you may have overflow or increased round off error; it is better to translate the polygon back to the origin, before doing the area calculation. How about these BETTER type signatures. -- Area of a Polygon import Data.List type X = Double type Y = Double type Area = Double poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)] areaPoly :: [(X,Y)] - Area areaPolyCalc :: (Area,(X,Y)) - (X,Y) - (Area,(X,Y)) Spoiler Alert! -- Functions Below! areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] bit of help with n-ary please...
I don't know if this is homework. I suppose what you mean is the following: I'm trying to replace an element in an n-ary tree and display the completed tree. A more precise specification might help. - is the tree ordered - are all the elements in the leaves (not internal nodes) - is the location of the element to be replaced given? -- if so how? - is the tree supposed to be balanced? On Sun, 8 Nov 2009 15:40:03 -0800 (PST), you wrote: Anybody? thanks spot135 wrote: Hi, Ok what im trying to do is replace an element in an n-ary and display the completed tree. So this is what ive got so far. snip -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] Is there a way to embed a Haskell interpreter/compiler in a browser. I think this would be a safer language than JavaScript.
Is there a way to embed a Haskell interpreter/compiler in a browser. I think this would be a safer language than JavaScript. -- Regards, Casey ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] Is there a way to embed a Haskell interpreter/compiler in a browser. I think this would be a safer language than JavaScript.
Is there a way to embed a Haskell interpreter/compiler in a browser. I think this would be a safer language than JavaScript. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Fwd: [Haskell-cafe] Haskell for Physicists
On Wed, 30 Sep 2009 21:24:11 +0200, you wrote: I?m a physicist, so I think they would be attracted by something like Haskell: high level physics modelling at Fortran speeds Haskell: mathematics beyond numerical calculus And, easier to make use of multi-core machines than threaded Fortran. I suppose one could have a Haskell parser convert Fortran to monadal code. Then, a parser to convert, hopefully, most of the resulting code to pure code. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language.
I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. If this is true, it needs to be pushed. And if by changing a few lines of source code one can develop a whole family of similar applications, that needs to be pushed, also. :) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language.
On Tue, 29 Sep 2009 18:19:08 -0700, you wrote: On Tue, Sep 29, 2009 at 5:24 PM, Casey Hawthorne cas...@istar.ca wrote: I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. If this is true, it needs to be pushed. And if by changing a few lines of source code one can develop a whole family of similar applications, that needs to be pushed, also. If you look through the archives here and elsewhere on the net, I think you'll see that technical superiority isn't the driving force for language adoption. It can help, but other factors seem to play a more significant role, usually dependent on context in which the languages became popular. At times it can seem like luck, but then I'm reminded of what Louis Pasteur said about luck and prepared minds. It is good that you're talking about Haskell though. Continue to discuss it with your peers and show them fun and cool things you've written using Haskell. I think this is more compelling for the uninitiated than statements about perceived technical power of the language. I've heard people explain this as, showing is better than telling. Cheers, Jason Hmmm! Like those people that are paid to go into coffee houses with some new technology, and then people see what they're doing and wander over and ask them questions about it. showing is better than telling. It's even being used by marketers/sellers. :) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Doing people's homework?
If you do a student's homework, you are cheating that student out of an education. He/She may realize that t late in the future. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc.
I think a language needs the following to exist: - a community - good library - a package manager Thoughts? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc.
On Tue, 29 Sep 2009 12:25:30 +1000, you wrote: I think one must distinguish what it means for a language to exist and be practical. Counter-example: Java fails catastrophically at all three and it most certainly exists; boy do I know it. QOTM! Casey Hawthorne wrote: I think a language needs the following to exist: - a community - good library - a package manager Thoughts? -- -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc.
On Mon, 28 Sep 2009 21:50:14 -0500, you wrote: Good libraries are not enough for a language to go beyond mere existence. There must exist good documents, i.e., good tutorials, good books, and good explanations and examples in the libraries, etc, that are easy for people to learn and use. In my humble opinion, Haskell has a lot of libraries, but most of them offer few examples of how to use the modules. In this regards, Perl is much much better. Good thought! Is there a good way to add Haskell examples to the libraries? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc.
On Mon, 28 Sep 2009 21:50:14 -0500, you wrote: Good libraries are not enough for a language to go beyond mere existence. There must exist good documents, i.e., good tutorials, good books, and good explanations and examples in the libraries, etc, that are easy for people to learn and use. In my humble opinion, Haskell has a lot of libraries, but most of them offer few examples of how to use the modules. In this regards, Perl is much much better. Good thought! Is there a good way to add Haskell examples to the libraries? A Haskell CookBook might be just the ticket, also. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] 16 bit floating point data in Haskell?
I think a 16-bit float type would require compiler revisions as opposed to doing something within the present type classes. This is similar to how Java would benefit from an unsigned byte primitive type for processing images, etc., whereas Haskell already has Word8. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] 16 bit floating point data in Haskell?
On Mon, 28 Sep 2009 12:06:47 +1300, you wrote: On Sep 28, 2009, at 9:40 AM, Olex P wrote: Hi, Yes, I mean sizeOf 2. It's useful not only on GPUs but also in normal software. Think of huge data sets in computer graphics (particle clouds, volumetric data, images etc.) Some data (normals, density, temperature and so on) can be easily represented as float 16 making files 200 GB instead of 300 GB. Good benefits. From the OpenEXR technical introduction: half numbers have 1 sign bit, 5 exponent bits, and 10 mantissa bits. The interpretation of the sign, exponent and mantissa is analogous to IEEE-754 floating-point numbers. half supports normalized and denormalized numbers, infinities and NANs (Not A Number). The range of representable numbers is roughly 6.0E-8 to 6.5E4; numbers smaller than 6.1E-5 are denormalized. Single-precision floats are already dangerously short for many computations. (Oh the dear old B6700 with 39 bits of precision in single-precision floats...) Half-precision floats actually have less than half the precision of singles (11 bits instead of 23). It's probably best to think of binary 16 as a form of compression for Float, and to write stuff that will read half-precision from a binary stream as single-precision, and conversely stuff that will accept single-precision values and write them to a binary stream in half-precision form. I agree with the above. I hadn't realized how dangerously short for many computations single-precision is. So, as he says, for computing, you do want to convert half-precision to single-precision, if not double-precision. If you want to save storage space, then some sort of compression scheme might be better on secondary storage. As for the video card, some sort of fast decompression scheme would be necessary for the half-precision numbers coming in. You are probably in the realm of DSP. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How does one delare a 2D STUArray in Haskell?
How does one delare a 2D STUArray in Haskell? I see the following from a diffusion program segment: module Diffusion where import Data.Array import Data.List (sortBy) type VFieldElem = Float type VField = Array (Int,Int) VFieldElem snip zeros = listArray ((1,1),(imax,jmax)) (repeat 0) From Real World Haskell to declare a 1D array (I changed some of the value names) there is the following: import Data.Array.ST (STUArray) import Data.Array.Unboxed (UArray) import Data.Word (Word32) data PlayingField1D a = PF1D { pf1DState :: (a - [Word32]) , pf1DArray :: UArray Word32 Bool } data MutPlayingField1D s a = MPF1D { mpf1DState :: (a - [Word32]) , mutpf1DArray :: STUArray s Word32 Bool } But I cannot see how to declare a 2D array. Although, it is not strictly necessary, pun intended, since one can reframe the 1D array as 2D array by using row/column mapping functions. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How does one delare a 2D STUArray in Haskell?
Well that makes sense, but for a learner, how is he/she supposed to know that 'i' could be '(i,i)' or for that matter a tuple of n of those i's? STUArray s i e Could you also have a tuple of states? Obviosly, 'e' could be a tuple, for instance (Int,Char) -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell
On Fri, 25 Sep 2009 23:25:21 +0200, you wrote: On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish jvran...@gmail.com wrote: Supposedly OCaml has an OO feature that does this but I haven't tried it out. Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. *# let f myobj = myobj#foo Hi !;; val f : foo : string - 'a; .. - 'a = fun* IIRC, there has been work on Template Haskell for structural polymorphism. Structural subtyping/polymorphism: Pros: - an object can be coerced to any compatible type, the types do not have to be specified ahead of time, that is at compile time. Cons: - may be overly permissive; some coercions might not make sense semantically. I wonder how Haskell will minimize the cons, since it is strongly typed. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell
On Fri, 25 Sep 2009 23:25:21 +0200, you wrote: On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish jvran...@gmail.com wrote: Supposedly OCaml has an OO feature that does this but I haven't tried it out. Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. *# let f myobj = myobj#foo Hi !;; val f : foo : string - 'a; .. - 'a = fun* IIRC, there has been work on Template Haskell for structural polymorphism. Structural subtyping/polymorphism: Pros: - an object can be coerced to any compatible type, the types do not have to be specified ahead of time, that is at compile time. Cons: - may be overly permissive; some coercions might not make sense semantically. I wonder how Haskell will minimize the cons, since it is strongly typed. I forgot to add: that even if strong typing could be measured on sum numerical scale, I don't know whether Haskell has a higher measure/metric than OCaml, in the strong typing area. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] line intersection code
Posting small packages like that on Hackage is a good way for others to learn Haskell. Is a record kept of suggested changes on Hackage? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Do I have this right? Remembering Memoization!
Do I have this right? Remembering Memoization! For some applications, a lot of state does not to be saved, since initialization functions can be called early, and these functions will remember - (memoize) their results when called again, because of lazy evaluation? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell#? F#?
The other morning, someone was telling me they had converted most of their VB financial/stock market code to F#. Whereas VB only used one core, the F# code used all four cores. In one software developers meeting, someone was saying that since database work is mostly all state, he didn't see the advantage of a functional programming language. It seems that, if you are doing at least moderately heavy computations, F# buys you a lot of speed on multiple cores. -- It now occurs to me that he was using an older version of VB, before .NET or for earlier versions of .NET. So maybe the use of multiple cores is now supported by .NET more so than the progamming languages on top of it. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell#? F#?
The other morning, someone was telling me they had converted most of their VB financial/stock market code to F#. Whereas VB only used one core, the F# code used all four cores. In one software developers meeting, someone was saying that since database work is mostly all state, he didn't see the advantage of a functional programming language. It seems that, if you are doing at least moderately heavy computations, F# buys you a lot of speed on multiple cores. -- It now occurs to me that he was using an older version of VB, before .NET or for earlier versions of .NET. So maybe the use of multiple cores is now supported by .NET more so than the progamming languages on top of it. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Uncontrolled Concurrency, isn't that concept now thread-bare?
-- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell on JVM
Since the JVM doesn't seem to support tail call optimization, I suppose one could could directly manipulate the bytecodes generated by jhc to do TCO. One challenge would be the garbage collector, since Haskell and Java have very different working sets of what is still being used. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Need some help with an infinite list
On Wed, 17 Jun 2009 00:45:56 -0400, you wrote: And here's a version along similar lines that avoids (++) for greater sharing and efficiency: let sss = [] : [ [ c:s | c - ['a'..'z'], s - ss ] | ss - sss ] in concat (tail sss) Sheer genius! I just inverted it since I like to see the main idea first. letterCombos = concat (tail sss) where sss = [] : [ [ c:s | c - ['a'..'z'], s - ss ] | ss - sss ] -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] When folding is there a way to pick out the last point being processed?
When folding is there a way to pick out the last point being processed? The first point can easily be picked out with (x:xs) but last xs crawls down the list. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] The speed, size and dependability of programming languages
Instead of GZip metrics for code size, maybe a good measure of imperative language code size would be the cyclomatic complexity metric. It would also be interesting to see results for Fortran, Java, C++, etc. across a range of old and newer compilers. Can one measure cyclomatic complexity for functional languages? However: From: http://en.wikipedia.org/wiki/Software_metric Modern software development practitioners are likely to point out that naive and simplistic metrics can cause more harm than good. ALSO: one is often more interested in Software Quality factors * 4.1.1 Understandability * 4.1.2 Completeness * 4.1.3 Conciseness * 4.1.4 Portability * 4.1.5 Consistency * 4.1.6 Maintainability * 4.1.7 Testability * 4.1.8 Usability * 4.1.9 Reliability * 4.1.10 Structuredness * 4.1.11 Efficiency * 4.1.12 Security Which seem only to be qualitatively metricable and not quantitatively metricable. Benchmarks of any type only seem to be applicable to your program if your program is fairly similar to the benchmark. -- Regards, Casey ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Articles on the value of strong typing
You may find the following comment interesting. The mythos of type systems is that they help the programmer. But the reality is compiler and hardware design. Not simply that a fantasy type system is harder to implement, but that a restricted language is easier to implement. page 189 Theoretical Introduction to Programming Bruce Mills Springer 2006 I don't know if he bases his conclusions on a study or not. I have been unable to find any such studies as it supposedly is common knowledge that strong type systems are of great value. Additionally the people I have asked the question was not aware of any such studies, so now I'm trying this list. Please note that I am looking for papers or articles, preferably from the academic community, and not personal opinions (as valid as they may be). -- Regards, Casey ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] The Q Programming Language can do symbolic manipulation -- Haskell?
The Q Programming Language can do symbolic manipulation -- Haskell? The Q Programming Language can do the following: sqr X = X*X ==sqr 5 25 ==sqr (X+1) (X+1)*(X+1) Can Haskell do symbolic manipulation? Or are term-rewriting and the lambda calculus sufficiently far enough apart concepts? -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe