I'm currently teaching myself Haskell, and I'm wondering what the best practices are when working with strings in Haskell.
The default string implementation in Haskell is a list of Char. This is inefficient for file input-output, according to Real World Haskell, since each character is separately allocated (I assume that this means tha...
Quickcheck and its variants (even there is one in java), seems to be interesting. However, apart from academic interest, is it really useful in a real application testing (Eg. a GUI application or Client/Server or even take StackOverflow itself)? Any experiences you had with similar test generators is appreciated.
...
What is Haskell's Stream Fusion and how do I use it?
...
God I hate the term "code smell", but I can't think of anything more accurate.
I'm designing a high-level language & compiler to Whitespace in my spare time to learn about compiler construction, language design, and functional programming (compiler is being written in Haskell).
During the code generation phase of the compiler, I have t...
One of the arguments I've heard against functional languages is that single assignment coding is too hard, or at least significantly harder than "normal" programming.
But looking through my code, I realized that I really don't have many (any?) use patterns that can't be written just as well using single assignment form if you're writing...
Hi,
I'm trying to implement a transparent cache that can load a specific object when it's not available, or return an already existing object indexed by (name).
I've tried running this:
loader' objs name = case findObj objs name of
Nothing → (new_obj, loader' new_objs)
Just obj → (obj, loader' objs)
where
new_objs = [(name...
I've been reading a number of tutorials on Haskell. However, I have not been able to get the compiled application to run on a multicore (I have an Intel Quad Core) on windows (32 bit).
I have tried a number of things:
ghc -O2 --make A.hs -threaded
./real-par +RTS -N2
./real-par +RTS -N4
But no luck.
The compiled application runs ...
I'm trying to understand what the dot operator is doing in this Haskell code:
sumEuler = sum . (map euler) . mkList
The entire source code is below.
My understanding:
The dot operator is taking the two funtions 'sum' and the result of 'map euler' and the result of mkList as the input.
But, 'sum' isn't a function it is the argume...
I'm trying to understand how Haskell list comprehensions work "under the hood" in regards to pattern matching. The following ghci output illustrates my point:
Prelude> let myList = [Just 1, Just 2, Nothing, Just 3]
Prelude> let xs = [x | Just x <- myList]
Prelude> xs
[1,2,3]
Prelude>
As you can see, it is able to skip the "Nothing" an...
It seems like there are plenty of examples of clever things being done in a lazily-evaluated language that can't be done in an environment with strict evaluation. For example infinite lists in Haskell or replacing every element in a tree with the tree's minimum value in one pass.
Are there any examples of clever things being done in a ...
Disclaimer: I'm new to Haskell and I don't remember a lot about FP from university, so there may be more than one or two errors in my code. This is also my code for Euler Problem 3.
I'm trying to recursively call a function with two arrays as arguments and an array as a result.
The goal:
assume n is 10 for this question
create a lis...
If I have an XML document like this:
<root>
<elem name="Greeting">
Hello
</elem>
<elem name="Name">
Name
</elem>
</root>
and some Haskell type/data definitions like this:
type Name = String
type Value = String
data LocalizedString = LS Name Value
and I wanted to write a Haskell function with the following signatu...
This is about syntactic sugar in Haskell. A simple Haskell program:
main = do
args <- getArgs
let first = head args
print first
I use binding in the first line (args <- getArgs) and a pure assignment in the second one (let first = ...). Is it possible to merge them together into a readable one-liner?
I understand that I can rew...
I've heard that Telecoms are the big source of Erlang jobs but I'm not sure how much of a market there is. How likely is it that someone could find a job in Erlang/Haskell if they decided to learn it? In my case I have a lot of programming experience in Java but am tired of Java and want to try something different.
...
I have created the following C library for reading an image:
typedef struct {
unsigned int height;
unsigned int width;
unsigned char* red; //length=height*width
unsigned char* green;
unsigned char* blue;
} Contents;
Contents readJPEGFile(const char* inFilename);
I can't really find any info using arrays and struc...
While learning Haskell I had the feeling that the authors where not always telling me everything, so to truly understand it I would like to know the theory behind the type system, monads and concepts like that.
Most of these concepts come from Category Theory I heard, so what are some good books/websites on this topic and related topics...
I am writing a program that runs an external sub process interactively and I need the contents of the output handle to be output to stdout as soon as it is available. I have tried something like this:
main = do processInfo <- createProcess (proc "ghci" []){std_out = CreatePipe,
std_in ...
I have used the ghci debugger but would really prefer if it was somewhat integrated with a text editor to simplify the process of setting breakpoints. It should probably not strictly evaluate every visible variable but at least simplify the process of looking at the local state.
I recently found the trace function which has been helpful...
Since both ruby and Haskell supports FFI,
Is it possible to call Haskell code from ruby, may be through FFI ?
Is there any Haskell binding in Ruby ?
...
Hey,
I've been looking at Haskell and I'd quite like to write a compiler (as a learning exercise) in it, since a lot of it's innate features can be readily applied to a compiler (particularly a recursive decent compiler).
What I can't quite get my head around is how to represent a language's grammar in a Haskell-ian way. My first thoug...