Re: [Haskell-cafe] IO help

2009-05-07 Thread Adrian Neumann
Have a look at the wikibook: http://en.wikibooks.org/wiki/Haskell/Simple_input_and_output Am 07.05.2009 um 11:46 schrieb applebiz89: I havent done much IO at all in haskell, only within the function itself. However I want to get the input from the interface for the function and havent

[Haskell-cafe] Unfold fusion

2009-05-06 Thread Adrian Neumann
Hello, I'm trying to prove the unfold fusion law, as given in the chapter Origami Programming in The Fun of Programming. unfold is defined like this: unfold p f g b = if p b then [] else (f b):unfold p f g (g b) And the law states: unfold p f g . h = unfold p' f' g' with p' = p.h

Re: [Haskell-cafe] Looking for the fastest Haskell primes algorithm

2009-04-15 Thread Adrian Neumann
I've just uploaded a package with some functions I had lying around. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Numbers Am 14.04.2009 um 14:40 schrieb Niemeijer, R.A.: Today I happened to need a large list of prime numbers. Obviously this is a well-known problem, so I

[Haskell-cafe] Re: [Haskell-beginners] appropriateness of haskell for GUIs

2009-03-21 Thread Adrian Neumann
Am 21.03.2009 um 13:30 schrieb Michael Mossey: Thomas Davie wrote: On 21 Mar 2009, at 00:16, Michael P Mossey wrote: Hello, I'm totally new to Haskell. I'm thinking of using it for a personal project, which is a gui-based musical score editor. The rough situation of GUI programming on

[Haskell-cafe] Re: [Haskell-beginners] laziness and optimization

2009-03-21 Thread Adrian Neumann
You should not rely on the compiler to spot such things. As far as I know GHC doesn't do automatic caching (in many cases that would hurt performance, I think). Have a look at http://haskell.org/haskellwiki/ Memoization perhaps. Am 21.03.2009 um 14:02 schrieb Michael Mossey: I understand

Re: [Haskell-cafe] Fw: hw do i solve this problems:

2009-03-19 Thread Adrian Neumann
http://lmgtfy.com/?q=haskell+run+length+codingl=1 But you'll learn nothing if you just copy that Am 19.03.2009 um 03:24 schrieb THANDO NTUANE: - Forwarded Message From: THANDO NTUANE thandodar...@yahoo.com To: Haskell-Cafe@haskell.org Sent: Thursday, March 19, 2009 10:22:40 AM

Re: [Haskell-cafe] Query on list comprehension

2009-03-18 Thread Adrian Neumann
Use a nested list comprehension, for example Prelude [['a'| i - [0..n]]++\n|n - [1..3]] [aa\n,aaa\n,\n] Am 18.03.2009 um 07:47 schrieb Melanie_Green: What are the limitations of list comprehension. I want to use listcomprehension to output the pattern below. So a mixture of a's and

[Haskell-cafe] Re: [Haskell-beginners] folds -- help!

2009-03-14 Thread Adrian Neumann
` alpha) And it works as long as oplus is strict in both arguments. Am 10.03.2009 um 21:54 schrieb John Dorsey: Adrian Neumann wrote: Notice that there is no difference between foldr g a foldl f a (for appropriate g and f) if g and f are strict in both arguments. Be careful... as apfelmus noted

Re: [Haskell-cafe] How to catch error in array index when debugging

2009-03-14 Thread Adrian Neumann
You can use the ghci debugger http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci- debugger.html it can set breakpoints on exceptions. Am 14.03.2009 um 09:39 schrieb Colin Paul Adams: I'm getting a runtime failure Error in array index. This causes ghci to exit. Is there a way

Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-11 Thread Adrian Neumann
Read this excellent paper: http://www.cs.nott.ac.uk/~gmh/fold.pdf Am 11.03.2009 um 19:24 schrieb R J: foldl and foldr are defined as follows: foldr:: (a - b - b) - b - [a] - b foldr f e [] = e foldr f e (x : xs) = f x (foldr f e xs) foldl

Re: [Haskell-cafe] Basic problem in Haskell language design?

2009-03-01 Thread Adrian Neumann
You could turn on -Wall to get a whole bunch of such warnings. Am 01.03.2009 um 14:26 schrieb Nicu Ionita: Hi, Today I found the following problem when writing a simple function: -- Whole info from a word8 list to moves movesFromWord8s :: [Word8] - [Move] movesFromWord8s (f:t:ws) = (f, t) :

Re: [Haskell-cafe] (Off-topic) CUDA

2009-02-06 Thread Adrian Neumann
Am 05.02.2009 um 09:10 schrieb Andrew Coppin: And so, inspired by the marketing litrature, I just spent £££ on a very expensive new GPU that supports CUDA. The only problem is... I can't seem to get any software to use it. Does anybody know how to make this stuff actually work? (Also...

[Haskell-cafe] ANNOUNCE: DecisionTree 0.0

2009-01-25 Thread Adrian Neumann
Hello, it is my pleasure to announce the DecisionTree package. It provides an implementation of the ID3 algorithm [1] and can be used to classify data with discrete valued attributes. You can get it from * hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ DecisionTree

Re: [Haskell-cafe] Elevator pitch for functional programming

2009-01-20 Thread Adrian Neumann
There was a thread about that: http://www.haskell.org/pipermail/haskell-cafe/2007-September/ 031402.html Am 20.01.2009 um 11:07 schrieb Jim Burton: Hi, I will be a TA on a comparative PL course and I'm looking for small examples (ammunition) which motivate the use of Haskell and functional

Re: [Haskell-cafe] definition of data

2008-12-31 Thread Adrian Neumann
You need some type constructor: data Tree a = Leaf a | Branch (Tree a) (Tree a) Am 01.01.2009 um 08:32 schrieb Max.cs: hi all, I want to define a data type Tree a that can either be a or Branch (Tree a) (Tree a)? I tried data Tree a = a | Branch (Tree a) (Tree a) deriving Show but it

Re: [Haskell-cafe] instance Enum [Char] where ...

2008-12-30 Thread Adrian Neumann
Better would be [] = 0 ['a'] = 1 ['b'] = 2 ... ['z'] = 26 ['a','a'] = 27 ['a','b'] = 28 (asuming Char = ['a'..'z']) Am 30.12.2008 um 04:25 schrieb JustinGoguen: I am having difficulty making [Char] an instance of Enum. fromEnum is easy enough: map fromEnum to each char in the string and

[Haskell-cafe] Data.List.sort, not so good?

2008-12-29 Thread Adrian Neumann
Hello Haskell-Cafe, lately I've been playing around with sorting. I discovered that Data.List.sort is not as optimized I thought. At least not for random lists. I think we should consider adding a Data.List.Sort package to hackage (Similar to Data.List.Split) that offers a wide variety of

Re: [Haskell-cafe] Data.List.sort, not so good?

2008-12-29 Thread Adrian Neumann
schrieb Bayley, Alistair: From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Adrian Neumann I don't consider myself to be a very advanced Haskell programmer, but I could come up with a Mergesort that beats List.sort, time- and spacewise. http://hpaste.org

Re: [Haskell-cafe] What are side effects in Haskell?

2008-12-23 Thread Adrian Neumann
Am 23.12.2008 um 15:16 schrieb Hans van Thiel: Hello All, I just saw somewhere that one of the purposes of monads is to capture side effects. I understand what a side effect is in C, for example. Say you want to switch the contents of two variables. Then you need a third temporary

[Haskell-cafe] Trouble with interact in ghci

2008-12-17 Thread Adrian Neumann
Hi, I have a strange problem with interact on OS X (ghc 6.10.1). It seems to garble stdin. I have some code here http://hpaste.org/13135#a2 , for testing purpose: *Main main 1 1.0 2 1.5 3 2.0 *Main setNonBlockingFD: invalid argument (Bad file descriptor) 11:40:45 ~/Desktop (I hit

Re: [Haskell-cafe] Compilers

2008-11-27 Thread Adrian Neumann
Am 27.11.2008 um 09:23 schrieb Don Stewart: allbery: On 2008 Nov 26, at 16:58, Matthias Kilian wrote: On Wed, Nov 26, 2008 at 09:35:01PM +, Andrew Coppin wrote: It is a fork of the JHC compiler, which should be easier to look up. There is also Hugs, as you mentioned. In addition, you

Re: [Haskell-cafe] Counting beta reductions for a Haskell program...

2008-11-21 Thread Adrian Neumann
Hugs has, afaik, a output reduction count option somewhere. At least it had one the last time I used it. - Adrian Am 22.11.2008 um 06:22 schrieb kk08: Thanks. I heard that a Gofer compiler (a Haskell dialect) supports counting the Beta reductions. Hence I thought GHC/Hugs would have a

Re: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0

2008-10-11 Thread Adrian Neumann
Thank you for your work! I just glanced over it but I'll suggest it to be linked to from the homepage of my university's functional programming course. However, thirteen pages can hardly be called cheatsheet. It's more like a quick reference. You could add [100,99..] infinite liste of

[Haskell-cafe] Re: Health effects

2008-10-02 Thread Adrian Neumann
of the line is equal. Does this work with more than two colours? i.e. can I recursively subdivide the halves into quarters with another cut? Am 01.10.2008 um 15:33 schrieb Dominic Steinitz: Adrian Neumann aneumann at inf.fu-berlin.de writes: I often wonder how many cuts you need

Re: [Haskell-cafe] Health effects

2008-10-01 Thread Adrian Neumann
I often wonder how many cuts you need to divide a steak in n pieces. You can obviously get n pieces with (sqrt n) cuts by cutting a grid. But I'm sure some smart mathematician thought of a (log n) way. Adrian Am 29.09.2008 um 21:43 schrieb Andrew Coppin: The other day, I sat down to eat a

Re: [Haskell-cafe] Looking for a more functional way to do this

2008-08-06 Thread Adrian Neumann
There is the State Monad which is build just for that kind of purpose, I believe: http://www.haskell.org/all_about_monads/html/statemonad.html That would safe you from passing around the State Jefferson Heard schrieb: Working with HOpenGL and GLUT, I find myself approaching a common problem

[Haskell-cafe] Exceptions

2008-07-27 Thread Adrian Neumann
Hello, I think it'd be nice if the compiler could warn me if there are any exceptions which I'm not catching, similar to checked exceptions in Java. Does anyone know of a possibility to do that in Haskell? Adrian PGP.sig Description: Signierter Teil der Nachricht

Re: [Haskell-cafe] Help with optimization

2008-07-20 Thread Adrian Neumann
Maybe your image isn't strict enough and the computations are forced when the image gets written to disc? Am 20.07.2008 um 14:13 schrieb Mitar: Hi! Profiling says that my program spends 18.4 % of time (that is around three seconds) and 18.3 % of allocations in this function which is saving

[Haskell-cafe] Fixed-Point Combinators

2008-07-16 Thread Adrian Neumann
Hello, while studying for a exam I came across this little pearl: Y = (L L L L L L L L L L L L L L L L L L L L L L L L L L L L) where L = λabcdefghijklmnopqstuvwxyzr. (r (t h i s i s a f i x e d p o i n t c o m b i n a t o r)) posted by Cale Gibbard to this list. Now I'm wondering how

Re: [Haskell-cafe] Compiling large code with old machine

2008-06-17 Thread Adrian Neumann
I would assume -O0, that is, turning off all optimizations, should make compilation faster Adrian Am 17.06.2008 um 14:19 schrieb Samuel Silva: Hello I'm using GHC to compile around 700K of Haskell Code generated by HaXml. How I compile this code. My machine is Windows-XP(512MB RAM,

[Haskell-cafe] (no subject)

2008-06-15 Thread Adrian Neumann
{- I downloaded the source and put my file in the same directory You may need to adjust the imports -} module Main where import Picture import Draw -- change xWin to 1000 and yWin to 700 for this to work import EnableGUI -- I use a Mac import SOE hiding (Region) import qualified SOE as G

Re: [Haskell-cafe] Lindenmayer Systems, WAS: (no subject)

2008-06-15 Thread Adrian Neumann
I screwed up the email, sorry about that. What I wanted to say was: Hello, as homework I was assigned to design and draw an image using the SOE Graphics library [1]. In order to impress my classmates I decided to draw a bush-like thingy using a Lindenmayer-System. It turns out quite nice

Re: [Haskell-cafe] cgi liftM liftIO

2008-06-14 Thread Adrian Neumann
I think you need to put liftIO in front of the IO actions you want to do inside the CGI Monad. Like in this example http://www.haskell.org/haskellwiki/ Practical_web_programming_in_Haskell#File_uploads (Why did I need to use google to find that? The wiki search in awful. Searching for

Re: [Haskell-cafe] Copying Arrays

2008-05-29 Thread Adrian Neumann
Isn't fast IO what ByteStrings where invented for? Adrian Tom Harper schrieb: I'm trying to implement some file I/O where I can read in a file to an array, but do so without having to know how much space I will need. (Before you suggest it, lists are too slow/space consuming.) I was thinking

[Haskell-cafe] appending an element to a list

2008-05-29 Thread Adrian Neumann
Hello, I was wondering how expensive appending something to a list really is. Say I write I'd say longList ++ [5] stays unevaluated until I consumed the whole list and then appending should go in O(1). Similarly when concatenating two lists. Is that true, or am I missing something?

Re: [Haskell-cafe] HTTP and file upload

2008-04-15 Thread Adrian Neumann
Yes http://hpaste.org/6990 Am 14.04.2008 um 19:07 schrieb Adam Smyczek: Is form based file upload supported in HTTP module (HTTP-3001.0.4)? Adam ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Windows CE, Xscale Compiler?

2008-04-04 Thread Adrian Neumann
Is there any Haskell compiler for Windows CE on a XScale platform? I googled around a bit and found references to a Hugs implementation but couldn't find any place to download it. I have the opportunity to program a teledrive[1] and would very much like to avoid something disfunctional like

[Haskell-cafe] HDBC, character encoding

2008-03-26 Thread Adrian Neumann
Hi, I wrote a CGI program to access a Postgres database using HDBC. The database stores books and I want to display those from a certain author. Everything works fine, unless I search for someone with an umlaut in his name. Böll, for example. I have a function like this bookByAuthor ::

[Haskell-cafe] Performance Issues

2008-01-29 Thread Adrian Neumann
Hello Haskell-Cafe! I've read about Control.Parallel and wanted to give it a try. Here's what I wrote: --- import Control.Parallel import Data.List splitList :: [Integer] - [[Integer]] splitList = unfoldr f where f [] = Nothing f ~x = Just (splitAt 3 x) map' :: (a-b) -

[Haskell-cafe] type trickery

2007-12-20 Thread Adrian Neumann
Hello haskell-cafe! After making data Number = Zero | Succ Number an instance of Integral, I wondered how I could do the same with galois fields. So starting with Z mod p, I figured I'd need something like this data GF = GF Integer Integer so that each element of the finite field would

[Haskell-cafe] Trees

2007-12-02 Thread Adrian Neumann
Good morning, as an exercise for my Algorithms and Programming course I have to program a couple of simple functions over trees. Until now everything we did in Java could be done in Haskell (usually much nicer too) using the naive data Tree a = Leaf a | Node a [Tree a] But now the

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-14 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 I heard only rumors, but isn't Lisp supposed to be just that? A programmable programming language? Peter Verswyvelen schrieb: This is all very cool stuff, but sometimes I wander if it isn't possible to drop the special languages for fiddling

[Haskell-cafe] Data.Binary Endianness

2007-09-10 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 I try to write a Windows Bitmap File using Data.Binary, but I have some trouble. For example, the internet states, that the magic number, that puts 'BM' in the first two bytes of the file is 19778. But when I put (19778::Word16) I get 'MB'

[Haskell-cafe] IO inside CGI

2007-08-24 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 I'm toying around with web programming in Haskell. I'm trying to write a script which GETs an id and returns a couple of random numbers. Something like this: cgiMain :: CGI CGIResult cgiMain = do inp - getInput id let gen = parse

[Haskell-cafe] Sudoku Solver

2007-08-06 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Hi, I wrote a brute-force sudoku solver. It takes a [[Int]] and spits out the first solution it finds. Why is it, that [0,0,0,7,0,6,9,0,0] [9,0,0,0,0,4,7,0,0] [7,0,0,0,0,0,4,0,0] [0,2,7,0,3,5,8,0,0] [6,9,5,8,2,0,0,0,0] [0,8,0,0,0,0,5,0,0]

[Haskell-cafe] Cannot compile Network.CGI programs

2007-05-26 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Hi, I installed the Network.CGI package and tried to compile the Hello World example on my Ubuntu machine. ghc cgi.hs -o cgi gives me cgi.o: In function `r1hk_info': (.text+0x56): undefined reference to

[Haskell-cafe] Intermediate Haskell Books?

2007-05-06 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Are there any good books about intermediate to advanced Haskell? The descriptions here http://haskell.org/haskellwiki/Books_and_tutorials aren't very helpful. Adrian -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using

[Haskell-cafe] The Trivial Monad

2007-05-04 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 I've read this blogpost about the trivial monad http://sigfpe.blogspot.com/2007/04/trivial-monad.html, because I still don't understand what this monad thingy is all about. The author defines three functions: data W a = W a deriving Show return

[Haskell-cafe] (newbie) instance Enum MyType where, smarter way?

2007-03-27 Thread Adrian Neumann
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Hello, I defined an enumeration datatype like this data MyType = One | Two | Four | Eight and want to make it an instance of the class Enum. deriving Enum won't do what I want, as it labels the items 0,1,2,3. Is there a better way to do this