haskell

Using Data.Heap in Haskell, or reading Haskell docs for a beginner

I'm trying to use Haskells Data.Heap module, but I'm incapable of even using it with integers. The only heap I've been capable of using is "empty", which does not take any arguments. Later on I'll figure out how to instance for my needs, but for now I'd be glad if I was even able to test it with numbers. ...

eclipseFP2 haskell unix haveing issues connectiong to Scion Server

I am having troubles with using FP2 for eclipse and getting it to connect with the server. Eclipse seems to auto-detect scion_server, but I a error in the log file !ENTRY net.sf.eclipsefp.haskell.scion.client 4 4 2010-04-15 10:40:06.580 !MESSAGE The connection with the Scion server could not be established. !STACK 0 The connection with...

Why is there "data" and "newtype" in Haskell?

To me it seems that a newtype definition is just a data definition that obeys some restrictions (only one constructor and such), and that due to these restrictions the runtime system can handle newtypes more efficiently. Ok, and the handling of pattern matching for undefined values is slightly different. But suppose Haskell would only kn...

ByteStrings in Haskell

So i am trying to write a program that can read in a java class file as bytecode. For this i am using Data.Binary and Data.ByteStream. The problem i am having is because im pretty new to Haskell i am having trouble actually using these tools. module Main where import Data.Binary.Get import Data.Word import qualified Data.ByteString.Lazy...

Haskell Type error

I am getting a Couldn't match expected type error on this code and am not sure why. Would appreciate it if someone could point me in the right direction as to fixing it. import qualified Data.ByteString.Lazy as S import Data.Binary.Get import Data.Word getBinary :: Get Word16 getBinary = do a <- getWord16be "Test.class" return (a) ...

Complete Haskore example

Does anyone know of a complete Haskore example that will take a small example and output a MIDI file? I'm looking for a starting point to start using Haskore and Google isn't turning up much. Thanks! ...

Continuation monad "interface"

The state monad "interface" class MonadState s m where get :: m s put :: s -> m () (+ return and bind) allows to construct any possible computation with State monad without using State constructor. For example, State $ \s -> (s+1, s-1) can be written as do s <- get put (s-1) return (s+1) Similarily, I never have to...

How can I make Cabal search for external programs?

I'm trying to write a Haskell program which requires the output of external programs (such as lame, the mp3 encoder). While declaring dependency on a library is easy in cabal, how can one declare dependency on an executable? ...

newbie question -- how does one override show for a newtype?

I want to override the default integer constructors in Haskell so they produce strings (mostly for curiosity, but temporarily to make a nice input alternative for LaTeX's \frac{}{} inconvenience). I wanted to be able to use the language itself, instead of a special parser, but I guess that's probably not going to work out... module Mai...

Type patterns in Haskell

I'm trying to compile a simple example of generic classes / type patterns (see http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-classes.html) in Haskell but it won't compile. Any ideas about what's wrong with the code would be helpful. According to the documentation there should be a module Generics with the data types Un...

Type error while trying to implement the (>>=) function in order to create a custom monad transformer.

Hello, I'm trying to create a monad transformer for a future project, but unfortunately, my implementation of the Monad typeclasse's (>>=) function doesn't work. First of all, here is the underlying monad's implementation : newtype Runtime a = R { unR :: State EInfo a } deriving (Monad) Here, the implementation of the Monad type...

Generate syntax-colored, hyperlinked source code from Haskell or Objective-C

Are there any packages that can take a directory full of source code (Objective-C and Haskell are the ones that interest me) and generate syntax-colored HTML from it where function names are links to their source code? ...

Project ideas for automated deduction/automated theorem proving?

Dear Stack Overflow brethren, I'm a second-semester junior who will embark upon my thesis soon, and I have an interest in automated deduction and automated theorem provers. As in, I'd like to advance the art in some way (I don't mean that pretentiously, but I do want to do something productive). I've Googled pretty far and wide and so...

Is functional GUI programming possible?

I've recently caught the FP bug (trying to learn Haskell), and I've been really impressed with what I've seen so far (first-class functions, lazy evaluation, and all the other goodies). I'm no expert yet, but I've already begun to find it easier to reason "functionally" than imperatively for basic algorithms (and I'm having trouble goin...

What's the "|" for in a Haskell class definition?

I can't figure out what the "| m -> w"-part means in a class definition like this: class (Monoid w, Monad m) => MonadWriter w m | m -> w What additional information does this add to the class definition? ...

Haskell: Problems with overloading: Interpreter can´t tell which + to use

Hi, I want to make functions Double -> Double an instance of the Num typeclass. I want to define the sum of two functions as sum of their images. So I wrote instance Num Function where f + g = (\ x -> (f x) + (g x)) Here the compiler complains he can´t tell whether I´m using Prelude.+ or Module.+ in the lambda expression. So I impor...

Haskell: Dealing With Types And Exceptions

I'd like to know the "Haskell way" to catch and handle exceptions. As shown below, I understand the basic syntax, but I'm not sure how to deal with the type system in this situation. The below code attempts to return the value of the requested environment variable. Obviously if that variable isn't there I want to catch the exception and...

Explain Type Classes in Haskell

Hi, I am a C++ / Java programmer and the main paradigm I happen to use in everyday programming is OOP. In some thread I read a comment that Type classes are more intuitive in nature than OOP. Can someone explain the concept of type classes in simple words so that an OOP guy like me can understand it? ...

Creating Haskell instance declarations

Hello, complete noob to Haskell here with probably an even noobier question. I'm trying to get ghci output working and am stuck on instance declarations. How could I declare an instance for "(Show (Stack -> Stack))" given: data Cmd = LD Int | ADD | MULT | DUP deriving Show type Prog = [Cmd] type Sta...

How are lists implemented in Haskell (GHC)?

I was just curious about some exact implementation details of lists in Haskell (GHC-specific answers are fine)--are they naive linked lists, or do they have any special optimizations? More specifically: Do length and (!!) (for instance) have to iterate through the list? If so, are their values cached in any way (i.e., if I call length...