Haskell is a purely functional programming language, featuring static typing, lazy evaluation, and monadic effects. The primary implementation is GHC, a high-performance compiler with a runtime supporting many forms of parallelism and concurrency.
3
votes
1answer
10 views
5
votes
1answer
48 views
5
votes
1answer
50 views
Poor AI for 2048 written in Haskell
I'm learning Haskell and thought it would be fun to write an AI for the game 2048 in Haskell.
In my implementation I got rid of the randomized aspects of the game.
This makes the program ...
1
vote
2answers
19 views
Implement a fold-like Function in Haskell
Let's say I need to write a function that applies a function to each item in a List, and then appends it to an accumulator. When the List is empty, return the accumulator.
...
5
votes
2answers
41 views
Decomposing bitfield with Haskell: is recursion the only way to do this?
Here's a program to take a bitfield like 7 and decompose it into the flags [1,2,4].
Ignore that the algorithm for doing this doesn't use bit shifting/is stupid.
Problems: it seems like I have to have ...
1
vote
0answers
20 views
Optimizing BFS code in Haskell
I wrote a BFS implementation that walks a tile-based field. It takes a function that should return true for walkable tiles and false for walls. It also takes the start and end points. It currently ...
10
votes
1answer
139 views
Probably unneeded returns
This is my first "useful" Haskell program. It's invoked with filenames as arguments where the last filename is the destination to which the content of all other files will be concatenated. As far as I ...
10
votes
0answers
120 views
Capture the notion of invertible functions
I find sometimes it is useful to capture the notion of invertible functions.
The idea is that if two functions f :: a -> b and ...
5
votes
2answers
51 views
Beta Reducer in Haskell
This is my first Haskell application, so any non-name-calling tips will be taken extremely well! It is just a beta reducer:
...
5
votes
1answer
62 views
Using Parsec for simple arithmetic language
I've been reading Types and Programming Languages and I wanted to try to implement the first language in Haskell to understand it properly
I have barely written any Haskell before and not used Parsec ...
3
votes
1answer
39 views
Knuth's algorithm M that produces mixed-radix numbers
This is the C++ code of my implementation of Knuth's algorithm M that produces mixed-radix numbers:
...
10
votes
1answer
106 views
Finding the next higher digital permutation of a number
This is my solution for CodeEval challenge 44.
The function followingInteger takes a number in its decimal representation and returns the next higher permutation ...
5
votes
1answer
101 views
Project Euler #15 in haskell
I've solved Project Euler #15 in Haskell, but I feel like there might be a better way to express my solution that I'm not seeing. I start out defining my types:
...
2
votes
1answer
49 views
Solve a maze in the form of a 2D array using BFS - Haskell
Suggestions for improving coding style are greatly appreciated.
...
3
votes
1answer
67 views
DSL for describing circuits
I am working on a micro project: a Haskell DSL for describing circuits.
(You can find the code here)
I'm pretty happy with everything so far, but there is an ugly function ...
5
votes
1answer
47 views
Find index of lowest unique integer in each line of the file
The code below finds the index of the lowest unique integer on each line of the file. The numbering starts at 1, and when there's no unique value, the 0 should be ...
3
votes
1answer
56 views
Split a string on spaces, accounting for backslash as escape character, in Haskell
This code works, but since I'm just learning Haskell I'm wondering if it could have been done in a more idiomatic way.
The main function is called tokenize, and it ...
5
votes
1answer
47 views
Conversion from decimal to negabinary and vice versa in Haskell
Recently I set about to writing conversion functions in Haskell between decimal and negabinary. I tried to write them in as much functional a style as possible, also aiming at brevity. Below I present ...
8
votes
3answers
870 views
PPM/PGM Image processing library in Haskell
EDIT: I changed encodePixel to use Builder, so this is how it looks:
...
7
votes
1answer
115 views
99 Haskell problems, problem 9: Pack function
Today I started to tackle the 99 Haskell problems (http://www.haskell.org/haskellwiki/99_questions). I had to struggle with problem 9 which requires to Pack consecutive duplicates of list elements ...
10
votes
1answer
114 views
(How) should I avoid writing procedural code in Haskell?
I'm trying to implement a left leaning red black tree as described here. This is their snippet for insert
...
1
vote
1answer
48 views
replacing explicit recursion with a fold
as an exercise I wanted to rewrite this toy python code in haskell.
...
6
votes
1answer
102 views
Game of Life implementation in Haskell
I've written a small Game of Life module in Haskell, as well as a small testing application. I'm relatively new to the language, so any kind of comment about the code is welcome. The most important ...
2
votes
1answer
36 views
optimizing a rollercoaster queue
I am working on a haskell exercise where I have to compute the amount of people riding a rollercoaster in a day. I have the following data: the number of rides in a day, the number of seats, and the ...
4
votes
1answer
49 views
Project Euler Problem 1 - Multiples of 3 and 5
I wrote this function for Project Euler Problem 1.
...
3
votes
1answer
92 views
99 Haskell Problems - Problem 2
Background
This is my first experience with functional programming and totally self-study. I just have 2-3 days' worth experience in Haskell. Now let's continue with actual code.
For Problem 2 of ...
2
votes
2answers
129 views
“Hell Difficulty” Haskell Fast & Hard
I'm a complete neophyte to Haskell with only a smidge of FP experience – I did some Racket programming academically and have written some semi-FP JavaScript professionally, but now I'm trying to learn ...
3
votes
1answer
81 views
Bresenham-like line algorithm
I implemented an algorithm that gives me a list of points that should be drawn in order the get a line between two points. Please note: it works only in a coordinate system whose origin (0,0) is in ...
7
votes
1answer
777 views
A boolean expression parser, written in Java
I was trying to write some of the Haskell list functions into Java, and I realized that one of the key strengths for many of the functions was the ability to pass in a boolean expression. I decided to ...
5
votes
1answer
101 views
Better or more idiomatic way to apply a sequence of functions in Haskell
This is one of my Haskell solutions to a variation of the N-Queens problem, where the queens can move like knights in addition to their normal moves. It has been optimised somewhat to avoid ...
4
votes
1answer
167 views
Function to produce unique random numbers
I've been learning Haskell for a few weeks after coming from a C# background. I've written a function to return a number of unique Ints from a specified range:
...
1
vote
1answer
92 views
block comment parser implementation for “monadic parser combinators”
I'm reading monadic parser combinators. On the page 23, they leave an exercise for defining a Gofer block comment parser, and I try to implement it in Haskell.
My code is here:
...
5
votes
1answer
90 views
3
votes
1answer
61 views
Rearrange content string
From https://www.codeeval.com/browse/115/:
You have a string of words and digits divided by comma. Write a program which separates words with digits. You shouldn't change the order elements.
I ...
4
votes
0answers
671 views
Performance of List representation of MonadPlus versus Tree representation
I am working on a code where I represent a MonadPlus using a Tree data structure and then explore it, summing over all of the ...
1
vote
3answers
92 views
How to simplify the record syntax with pattern matching?
I've just finished reading Learn You a Haskell and I've started to experiment on my own. I just wanted to create a very simple game system where player A can attack player B.
Now I have 2 questions:
...
0
votes
0answers
86 views
Optimizing my Quadratic Sieve, with advice on style?
I'm still new to Haskell, and I'd like others' opinions on optimizing my basic quadratic sieve, in addition to feedback on the code's clarity and functional style.
The ...
1
vote
0answers
54 views
Toy Forth interpreter
So I've been reading too much papers and writing too little code. These are my first 300 lines of Haskell:
...
1
vote
1answer
82 views
Math formulas in Haskell
I wrote some math formulas in Haskell and was wondering about how to clean the code up and make it more readable.
...
2
votes
2answers
209 views
Usage of lens for concise update of records
I'm new to Haskell. I'm developing a game-like simulation. I try to use lenses to update the state of the world.
Current iteration of code works, but looks clumsy. I am trying to improve it, e.g. I ...
6
votes
1answer
141 views
Automata theory, state reachability in Haskell
I wrote a small library to learn Haskell while studying Automata theory. I have some concerns on my algorithm to evaluate state reachability. That is, I think it might be improved if I can avoid ...
2
votes
2answers
197 views
Haskell grep simplification
I am new in haskell and for start I choosed to write simple grep. Now I want to ask if there is some simplier/shorter way to write it. For example if there is any way to avoid recursion.
...
2
votes
1answer
103 views
6
votes
0answers
121 views
Mixed Drink Calculator in Haskell
This is a simple mixed drink calculator written in Haskell.
There are two input files. The drinks file contains a list of simply formatted recipes for mixed ...
3
votes
1answer
267 views
Graham Scan convex hull algorithm
I'm beginning learning Haskell. I've implemented the Graham Scan algorithm for detection of convex hull following the Real World Haskell book.
I'm looking for general advice regarding the style and ...
1
vote
1answer
123 views
Too much IO/State passing around
I've written a vocabulary trainer which does a lot of passing state around, as I have an ACID-database and a temporary state.
In my experience with Haskell I've learnt that overusing ...
3
votes
1answer
70 views
Code Review of Haskell PBKDF2
Moved from Programmers.SE.
I have written a new version of the PBKDF2 algorithm in Haskell. It passes all of the HMAC-SHA-1 test vectors listed in RFC 6070, but it is not very efficient. How can I ...
0
votes
1answer
115 views
99 Haskell problems, problem 18
The problem is here, the solutions are here. I don't see a solution like mine (maybe the 4th), it seems to work though.
...
1
vote
1answer
141 views
Hex to ASCII conversion in Haskell
I wrote a simple program in Haskell which takes Hex input from stdin, converts the input to ascii and writes it to stdout. An example use:
...
2
votes
1answer
86 views
Reading [String] where each item have a different type in Haskell
I have a data structure called ClientSession which I convert to a String separated by | for ...