[Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread ender
Hi all:      I'v been learning haskell for several months, and now I'm trying to write some real word program in haskell, like finding files under one directory or something      My problem is that, I dont know the way of writing a loop in haskell. I searched google and found some code that

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread Henning Thielemann
On Sun, 19 Dec 2010, ender wrote: do alloca $ \value - do poke value (50::Int) allocaArray 4 $ \part_stack - do alloca $ \part_ptr - do poke part_ptr part_stack let loop = do val - peek value if val == 0 then return () else do p - peek part_ptr

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread Mihai Maruseac
On Sun, Dec 19, 2010 at 12:27 PM, ender crazyen...@gmail.com wrote: Hi all:      I'v been learning haskell for several months, and now I'm trying to write some real word program in haskell, like finding files under one directory or something      My problem is that, I dont know the way of

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread Ivan Lazar Miljenovic
On 19 December 2010 21:27, ender crazyen...@gmail.com wrote: Hi all:      I'v been learning haskell for several months, and now I'm trying to write some real word program in haskell, like finding files under one directory or something      My problem is that, I dont know the way of writing a

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread ender
2010/12/19 Henning Thielemann lemm...@henning-thielemann.de: On Sun, 19 Dec 2010, ender wrote:  do  alloca $ \value - do  poke value (50::Int)  allocaArray 4 $ \part_stack - do  alloca $ \part_ptr - do  poke part_ptr part_stack  let loop = do           val - peek value           if

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread Lennart Augustsson
Recursion replaces loops. If it needs to be monadic or not depends on what you want to do. On Sun, Dec 19, 2010 at 10:53 AM, ender crazyen...@gmail.com wrote: 2010/12/19 Henning Thielemann lemm...@henning-thielemann.de: On Sun, 19 Dec 2010, ender wrote: do alloca $ \value - do

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread ender
2010/12/19 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com: On 19 December 2010 21:27, ender crazyen...@gmail.com wrote: Hi all:      I'v been learning haskell for several months, and now I'm trying to write some real word program in haskell, like finding files under one directory or

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread Ivan Lazar Miljenovic
On 19 December 2010 21:53, ender crazyen...@gmail.com wrote:   Thanks for your quick reply. So recursive and monad is the proper way to simulate loop,right? Well, recursion (either explicitly or implicitly via map, fold, etc.) rather than iteration (i.e. a loop) is the usual approach in

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread Henning Thielemann
On Sun, 19 Dec 2010, ender wrote: Hi Henning: Thanks for your quick reply. So recursive and monad is the proper way to simulate loop,right? I kept close to your suggestion, but avoiding monads, especially IO, is a good idea. If you do not need low-level memory access with peek and poke,

[Haskell-cafe] enumsets in ArchLinux but not in Hackage

2010-12-19 Thread Henning Thielemann
I found the package 'enumsets' in ArchLinux: http://aur.archlinux.org/packages.php?ID=18116 This points to Hackage, but there is no such package. It sounds like something I could need: A simple Haskell 98 wrapper around Word32, Word16, Word8, that are interpreted as bitfields, providing set

Re: [Haskell-cafe] Bifold: a simultaneous foldr and foldl

2010-12-19 Thread Larry Evans
On 12/07/10 12:36, Henning Thielemann wrote: Noah Easterly wrote: Somebody suggested I post this here if I wanted feedback. So I was thinking about the ReverseState monad I saw mentioned on r/haskell a couple days ago, and playing around with the concept of information flowing two

Re: [Haskell-cafe] handling multiple versions of a data structure

2010-12-19 Thread Dmitry V'yal
On 17.12.2010 01:09, Jeremy Shaw wrote: Hello, You should use happstack-data for this (you do not need the other happstack components to use happstack-data)*. It was created to solve this exact problem. happstack-data builds on type of the 'binary' library and adds versioned data types and

[Haskell-cafe] cabal dependency on code repositories.

2010-12-19 Thread Greg Weber
Michael Snoyman and I were discussing the need for beta releases of Yesod and he encourage me to post this to the cafe. Beta releases could be built into the hackage system. However, this can be viewed as a more general problem of distributing multiple versions of code (stable vs. experimental,

Re: [Haskell-cafe] IO, sequence, lazyness, takeWhile

2010-12-19 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/13/10 09:15 , Jacek Generowicz wrote: untilQuit' = (fmap (takeWhile (/= quit))) (sequence $ map (= report) (repeat getLine)) -- The latter version shows the report, but it doesn't stop at the -- appropriate place, so I'm guessing that I'm

Re: [Haskell-cafe] enumsets in ArchLinux but not in Hackage

2010-12-19 Thread Ivan Lazar Miljenovic
On 19 December 2010 23:54, Henning Thielemann lemm...@henning-thielemann.de wrote: I found the package 'enumsets' in ArchLinux:  http://aur.archlinux.org/packages.php?ID=18116 This points to Hackage, but there is no such package. It sounds like something I could need: A simple Haskell 98

Re: [Haskell-cafe] enumsets in ArchLinux but not in Hackage

2010-12-19 Thread Henning Thielemann
On Mon, 20 Dec 2010, Ivan Lazar Miljenovic wrote: On 19 December 2010 23:54, Henning Thielemann lemm...@henning-thielemann.de wrote: I found the package 'enumsets' in ArchLinux:  http://aur.archlinux.org/packages.php?ID=18116 This points to Hackage, but there is no such package. It sounds

[Haskell-cafe] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-19 Thread gutti
Hi, I'm very new to Haskell and this Forum, just doing my first steps ... -- Try to use the hmatrix package for vector and matrix calculations. The haskell compilation works (no problem in GHCi mode), the gcc however compilation fails with messages like: EFA.o: In function `r1bo_info':

Re: [Haskell-cafe] IO, sequence, lazyness, takeWhile

2010-12-19 Thread Jacek Generowicz
On 2010 Dec 19, at 20:10, Brandon S Allbery KF8NH wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/13/10 09:15 , Jacek Generowicz wrote: untilQuit' = (fmap (takeWhile (/= quit))) (sequence $ map (= report) (repeat getLine)) -- The latter version shows the report, but it doesn't

Re: [Haskell-cafe] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-19 Thread Jason
Hi Phil, I hope your Haskell journey so far has been enjoyable. I'm rather new myself, but I'm pretty sure the answer to your question is: By default, ghc doesn't try to include all the libraries that you import when you compile with ghc test.hs. You can either specify these manually: ghc

Re: [Haskell-cafe] IO, sequence, lazyness, takeWhile

2010-12-19 Thread Daniel Fischer
On Sunday 19 December 2010 22:18:59, Jacek Generowicz wrote: The reason this doesn't stop where you expect it to is that sequence is effectively strict That would explain it. Thank you. Where is this fact documented? I mostly rely on Hoogle, which gets me to

Re: [Haskell-cafe] enumsets in ArchLinux but not in Hackage

2010-12-19 Thread Ivan Lazar Miljenovic
On 20 December 2010 06:43, Henning Thielemann lemm...@henning-thielemann.de wrote: Maybe it's referring to (or you could use) one of the following: * http://hackage.haskell.org/package/EnumContainers * http://hackage.haskell.org/package/EnumMap No they are different, they rely on containers'

Re: [Haskell-cafe] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-19 Thread gutti
Hi Jason, many,many thanks - it works. -- u saved the day Haskell rather seems like a steeper slope to be honest, but I find the whole language concept very fascinating. What I can't imagine yet, how to address typical oo-problems especially when its not allowed to update and change

Re: [Haskell-cafe] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-19 Thread Henk-Jan van Tuyl
On Sun, 19 Dec 2010 21:32:00 +0100, gutti philipp.guttenb...@gmx.net wrote: Try to use the hmatrix package for vector and matrix calculations. The haskell compilation works (no problem in GHCi mode), the gcc however compilation fails with messages like: EFA.o: In function `r1bo_info':

Re: [Haskell-cafe] cabal dependency on code repositories.

2010-12-19 Thread Duncan Coutts
On 19 December 2010 17:44, Greg Weber g...@gregweber.info wrote: Michael Snoyman and I were discussing the need for beta releases of Yesod and he encourage me to post this to the cafe. Beta releases could be built into the hackage system. However, this can be viewed as a more general problem

Re: [Haskell-cafe] IO, sequence, lazyness, takeWhile

2010-12-19 Thread Carl Howells
Sequence isn't necessarily strict. Sequence, rather necessarily, depends on the semantics of (=) in that monad. Prelude Control.Monad.Identity runIdentity $ take 10 `liftM` sequence (map return $ repeat 5) [5,5,5,5,5,5,5,5,5,5] What matters is if (=) is strict in its first argument. The

Re: [Haskell-cafe] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-19 Thread Jason
Phil, I found Haskell to be a pretty steep slope at first too, but it helped me to start out small and work my way up. And now its my favorite tool in the arsenal! One of the steps I took was to do quite a few of the Project Euler ( http://projecteuler.net/) problems, and then after cobbling