haskell

How can I set up a simple test with Cabal?

I have a Haskell project and Cabal package-description that allows me to build and install my package with $ cabal configure $ cabal build $ cabal install But what about cabal test? Cabal's help says to configure a test suite with UserHooks, but how can I do that? ...

Which XML parser for Haskell?

I'm trying to write some application, that performs analysis of data, stored in pretty big XML files (from 10 to 800MB). Each set of data is stored as single tag, with concrete data specified as attrobutes. I'm currently saxParse from HaXml, and I'm not satisfied with memory usage during work with it. On parsing of 15Mb XML file it cons...

On Cygwin, how do I install curl from hackage?

From a Windows command prompt, c:\>cabal install curl Resolving dependencies... Configuring curl-1.3.5... cabal: Error: some packages failed to install: curl-1.3.5 failed during the configure step. The exception was: sh: runGenProcess: does not exist (No such file or directory) I have installed Cygwin's curl-devel package, but from a C...

Problems with scrolling in TextView in Gtk2hs and Haskell.

I'm writing my first gtk2hs+glade application, and I'm using a textview to display output from the program. Instead of scrolling which I thought was supposed to be the default behavior, the textview gets bigger everytime I re-set the text, and makes my buttons below it smaller until they disappear, but the scroll bars never pop up, and i...

Haskell: Overlapping instances

Consider the following example program: next :: Int -> Int next i | 0 == m2 = d2 | otherwise = 3 * i + 1 where (d2, m2) = i `divMod` 2 loopIteration :: MaybeT (StateT Int IO) () loopIteration = do i <- get guard $ i > 1 liftIO $ print i modify next main :: IO () main = do (`runStateT` 31) . runMaybeT . forever $ lo...

Where can I learn how best to represent procedural code in a language-independent manner ready for transformations?

Hi, For my source-code transforming (Fortran and C) numerical automatic differentiation engine project PARADE, I need a language-independent representation of procedural program code. The IL (intermediate language) in the below diagram: (The whole tool will be developed solely using Haskell, so strip Java from the above diagram where...

Type classes in Haskell data types

In Haskell, one can define a data type like so: data Point1 = Point1 { x :: Integer , y :: Integer } Can one use type classes for variables inside a data type? If so how? I realize it is possible to do this as an algebraic data type, with a different definition for each kind of point, but I'm wondering if there...

Haskell: generic IORef, MVar?

Hi, I made the following function which is specific for the IO monad: memoIO :: MonadIO m => m a -> IO (m a) memoIO action = do ref <- newMVar Nothing return $ do x <- maybe action return =<< liftIO (takeMVar ref) liftIO . putMVar ref $ Just x return x Example usage: main :: IO () main = do p <- memoIO $ putStrLn "...

How to make this code more compact and readable?

I am a Java programmer who learns Haskell. I've written a small program that searches files for words with a particular suffix. I'd like to read your criticism. What would you suggest to make this code more compact and readable? module Main where import Control.Monad import Data.String.Utils import Data.List import Data.Char import Sy...

Simple Haskell graphics library?

I'd like to experiment with Haskell a bit, and I'm hoping to write a small 2D arcade game (Tetris or Breakout). Can you recommend a simple graphics library that will help me to get started quickly? Btw, I've been experimenting with SDL and wxWidgets, but haven't yet succeeded in running any samples because of dependency problems, workin...

Haskell Build Automation

What is the preferred way to automate build/test/ci/doc-gen/... for a Haskell project? At the moment I use Cabal for the "final" build and bash-scripts to automate testing/checkins/doc-gen/.. but I would like to replace the bash-scripts. I've installed Nemesis (rake for Haskell according to the author) but I'm not yet sure it's the rig...

Haskell cabal+hsc2hs

Can cabal use hsc2hs to create hs files? How? I didn't find an answer in the manuals, googling, nor in other projects (had my hopes up for gtk2hs but it turns out that it doesn't use cabal) ...

Generating Fibonacci numbers in Haskell?

In Haskell, how can I generate Fibonacci numbers based on the property that the nth Fibonacci number is equal to the (n-2)th Fibonacci number plus the (n-1)th Fibonacci number? I've seen this: fibs :: [Integer] fibs = 1:1:zipwith (+) fibs (tail fibs) I don't really understand that, or how it produces an infinite list instead of one c...

What are some good intermediate problems and projects for learning Haskell?

I just recently started diving into Real World Haskell and the book provides some good practice exercises. However, I'd like some suggestions for specific problems people have solved or projects they've completed that have really helped them to better understand the language and its capabilities. What sort of things can I throw myself a...

Real world Haskell programming

Having been an imperative developer for some years now, I had never had the urge to learn functional programming. A couple months ago at last I decided to learn Haskell. It's quite a cool language, but I'm puzzled about how an event driven real app would be programmed in such a language. Do you know of a good tutorial about it? Note: W...

mail reader using haskell

I was trying to create a mail reader application using haskell. I found HaskellNet library for the same. Unfortunately there is no documentation or tests. Anyone knows how to use this library? ...

How can I initialize state in a hidden way in Haskell (like the PRNG does)?

Hi, I went through some tutorials on the State monad and I think I got the idea. For example, as in this nice tutorial: import Data.Word type LCGState = Word32 lcg :: LCGState -> (Integer, LCGState) lcg s0 = (output, s1) where s1 = 1103515245 * s0 + 12345 output = fromIntegral s1 * 2^16 `div` 2^32 getRandom :: State LCG...

Are list comprehensions a major part of Haskell

I looked at various Haskell resources on the web, before buying the book, Real World Haskell. Being otherwise excellent, it doesn't seem to contain anything about list comprehensions which I saw mentioned in the various websites I looked at. Could this just be because they are generally unused in well written Haskell for some reason, or ...

How do I combine monads in Haskell?

Particularly, I need to be able to combine the CGI monad with the IO monad, but an example of how to combine the IO monad with the Maybe monad might be even better... ...

Haskell: monadic takeWhile?

I have some functions written in C that I call from Haskell. These functions return IO (CInt). Sometimes I want to run all of the functions regardless of what any of them return, and this is easy. For sake of example code, this is the general idea of what's happening currently: Prelude> let f x = print x >> return x Prelude> mapM_ f ...