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.
2
votes
2answers
17 views
Haskell Arithmetic Quiz
I'm currently learning Haskell, and as one of my first "proper" programs have created a mathematics quiz. It works like this:
A question is generated, with two numbers from 1 to 10 which need to be ...
2
votes
3answers
33 views
CodeAbbey #21 Array Counters
I'm trying to learn some Haskell by working my way through the CodeAbbey problems. I really struggled to find a nice functional (but still efficient) way to solve problem #21: Array Counters.
The ...
4
votes
3answers
50 views
Textbased User Interface for user and program taking turns
I wrote this program to model interactions between a user and an artificial player, both playing by the same rules (not enforced here for simplicity).
The game played is here is "your next word has to ...
1
vote
2answers
47 views
Small haskell text-processing script
I'm a bioinformatician and mainly use python, but I'm trying to learn Haskell. So far I like this language because it's beautiful and fun, but my Haskell scripts usually end up being much slower than ...
3
votes
1answer
37 views
“Log in”, extract number from a map, increment it, and log out
Basically, you just run main and it allows the client to "log in", and extract their number from a map, increment their own number, and log out.
It all compiles ...
1
vote
1answer
23 views
Encoding and decoding in Haskell — 99 Problems exercise 13, 14
I've been working on these solutions to the Haskell 99 questions, encoding and decoding series for a while now, so I figured I ought to present them to see how I screwed up the implementation.
...
9
votes
1answer
264 views
Neural Network in Haskell
Following this website I wrote a neural network which uses the MNIST training data to recognize digits. The author writes that it should take a couple of minutes to train the network with 30 epochs of ...
3
votes
1answer
54 views
Haskell Parsec parser of Verilog-style number literals
I've set myself the task to write a function that parses Verilog-style number literals. In Verilog, numbers are written like this:
8'b10101100, ...
4
votes
2answers
70 views
Number Guessing Game in Haskell
I've been learning a lot about functional programming lately and I've recently started learning Haskell to which I'm very new.
I've written a simple number guessing game and I would like to have ...
3
votes
2answers
27 views
Finding Permutations in Haskell
I wrote a function to find all the possible permutations of a list in Haskell. I know it can definitely be optimized, but I'm not sure how. I'm pretty sure foldl or ...
4
votes
1answer
51 views
Implementation of Point, Velocity and Acceleration in Haskell
I'm trying to implement point, velocity and acceleration types.
They should be connected by some derive function which:
takes time and velocity and returns a ...
2
votes
2answers
43 views
Termbin.com clone (commandline pastebin)
For fun I decided to write a 'real' Haskell program. The intention of the program is that it listens on a socket on a given port for input. The client can send some raw text on it and the server ...
3
votes
0answers
46 views
AVL Tree Implementation in Haskell
I'd like to get some feedback on my AVL tree implementation. I appreciate any comments related to style and performance, particularly if something can be written in a more concise or idiomatic way. If ...
1
vote
0answers
26 views
Parametric HOAS and graph reification
Is it possible to reify the graph of lambda terms expressed as parametric HOAS. Not quite sure if it is
...
7
votes
1answer
66 views
Fraction or integer parser
Question
How can the following implementation of fractionParse be made
less ugly? (Preserving unreduced numerators and denominators is supposed to be a feature---...
2
votes
0answers
62 views
Low performance of HTTP request using Haskell wreq
The program makes HTTP requests (checks video stream status) and calls an external program.
...
2
votes
1answer
30 views
Filtered date range function
I want to write a function to produce an inclusive range of Day such that Saturdays are excluded.
...
5
votes
1answer
82 views
Basic Nim game in Haskell
I am starting to learn Haskell, and following Dr. Erik Meijer lectures online, he suggests as an exercise to implement the game of Nim in Haskell, so I implemented a really basic game for two players (...
4
votes
2answers
111 views
I can has(kell) moar cheezburgers?
KITTEH HAS IMPROOVD CODE SKILLS, AN NAO HAS BETTR CODE 4 U
This is an improvement of my original Haskell Lolcats Translator, and now features a function to do the translation (recursively?) using a ...
24
votes
4answers
5k views
I can has(kell) cheezburger?
Edit 13 June:
I have made a new and improved version here.
Original Question
This is a very rudimentary lolcats translator (it only works on the phrase "Can I have a cheeseburger") in Haskell. This ...
3
votes
1answer
63 views
Symmetry analysis for atom arrangements in a crystal
For a while now I've been meaning to post some of my Haskell code here so that someone can tell me what parts of the language/base library I've been completely overlooking. This is the first thing I'...
13
votes
3answers
1k views
Using Fibonacci sequence to generate musical melodies
I recently started picking up the Haskell programming language. I've managed to learn other languages rather quickly, but I'm still having a difficult time grasping some of the basics of Haskell.
I ...
0
votes
1answer
48 views
Composing IO and Async in haskell
Whether based on MVar or TVar, async implementation are always based on operation on some underlying monad IO and STM.
Making Async a monad on its own, as in F# async computation builder, if done in ...
2
votes
2answers
72 views
Print out a Zig-Zag Matrix in Haskell
My task is to code something that prints out this:
This is what I have done so far.
...
-2
votes
1answer
28 views
Capture some state in Haskell
I want to capture some state in a Haskell function. For instance, I have many thread trying to print on the console and I want the to play nice with each other. So I want to have some XX to make the ...
-5
votes
3answers
95 views
Refactor code to be more succinct but yet preserve the distinction of the `if`
the below code does what it needs to do. However I would like to know if there are better (shorter) ways to express the below while maintaining the explicitness of showing the decision like with the ...
3
votes
0answers
78 views
Zipper trees implementation
Considering the lack of general purpose library to manipulate trees (not to mention zipper ones), I may end up packaging this piece of code, so I would like it to be reviewed first.
Any comment is ...
26
votes
1answer
2k views
Charmander Brainfuck interpreter in Haskell
I just started learning Haskell and this is my first big project (ie not factorials, fibonacci or graphers). This is kind of a gift for somebody so the language is a bit different. The program works, ...
4
votes
1answer
48 views
LEB128 in Haskell
I have implemented the LEB128 encoding for unsigned integers. I'm fairly new to Haskell so I have some doubt about the coding style I'm using, particularly the definition of ...
6
votes
4answers
176 views
Get Nth item from end of list
I am starting out in Haskell and thought I would try to make a function that got the index (nth) from the end of the list.
So getNthFromEnd 5 [1..10] would equal 5
...
3
votes
1answer
42 views
Converting images to greyscale using JuicyPixel
I would like to use Haskell to do some image processing so I have been writing small programs to test performance. I wrote a program to batch convert PNG images from color to greyscale. I compared the ...
1
vote
1answer
48 views
Haskell Non-Dominated sorting
This algorithm sorts a list of Individuals, each with two fitness values, into what's called non-dominated fronts. A non-dominated front is a set of individuals where none of the individuals dominate ...
3
votes
0answers
64 views
Over-engineered fizzbuzz
I've got this fizzbuzz project I am using for a blog series, among other things. In this version, the fizzbuzz function is fed from a Fibonacci generator. I'm particularly concerned with the ...
1
vote
0answers
25 views
Implement “at” lens for Data.Map
I've been working on adding an operation like Data.Lens.At.at to Data.Map. This uses an extremely fast, extremely small, and ...
3
votes
2answers
90 views
Convert Roman Numeral to Arabic
I've been learning Haskell recently and I decided I needed to work on a (somewhat) realistic problem.
What I'm most interested in getting feedback on is how well I've used the tools in Haskell to ...
1
vote
1answer
87 views
FIRST and FOLLOW sets calculator in Haskell
I found myself wanting to brush up on some notions about parsers and grammars and, at the same time, to exercise my Haskell - I am a Haskell newbie; moreover, I haven't touched the language at all in ...
1
vote
1answer
53 views
Playing with event-sourcing
I'm playing around with some ideas about how to read aggregates from events.
From a high-level view I would love to have this:
...
2
votes
0answers
22 views
Unification with sequence variables and flexible arity functions
Today I wrote an implementation of the unification algorithm found in Temur Kutsia's 2002 paper. I didn't just do this for fun, it's related to other research I'm doing. I'm feeling more confident in ...
3
votes
1answer
33 views
Haskell Pig Latin Translator - v2
Thanks to Gurkenglas for the help with the previous iteration: Haskell - Pig Latin Translator!
Given the constraint that the newtypes are required, what ...
3
votes
1answer
55 views
Haskell - Pig Latin Translator
What improvements can I make to the following Pig Latin translator? So far, I've been wondering about the FlexibleInstances declaration, but I can't think of how to ...
3
votes
2answers
53 views
Idiomatic Leap years in haskell
I wrote a simple function to determine if a year is a leap year or not. It works, but does not feel idiomatic.
...
7
votes
2answers
126 views
Bucket sort in Haskell
As a first step in learning Haskell I am solving this problem, which involves finding the Rith-ranked numbers, given some input list and many Ri. In an imperative language I would make a zeroed array ...
3
votes
1answer
114 views
Simple Haskell Chess
Just for fun I tried to write a chess game in Haskell, in the hope that it would eventually be good enough to beat me. It's not perfect at the rules (it doesn't know about promotion, castling or en-...
3
votes
1answer
61 views
2
votes
2answers
57 views
Determine whether input-output pairs represent something that could be a proper math function
The input is read in line by line from stdin.
Input Format
The first line contains an integer, T, denoting the number of test
cases. The subsequent lines describe T test cases, and the ...
2
votes
2answers
59 views
U2 puzzle in Haskell
Here is a puzzle:
U2 has a concert that starts in 17 minutes and they must all cross a bridge to get there. All four men begin on the same side of the bridge. You must help them across to the ...
6
votes
1answer
80 views
Data structure for expression evaluation in Haskell
I've made a data structure for mathematical expressions. I want to parse mathematical expressions like:
\$x = 3\$
\$y = 4\$
\$z = x + y :\$
into an evaluated document like:
\$x = 3\$
\$y = 4\$
\$...
5
votes
1answer
56 views
`read` re-implemented for Int's
I have written a safe read function for haskell (for education!). I think this is fairly idiomatic haskell code, but I'd like to know for sure. If you see anything else that could be improved, please ...
4
votes
3answers
65 views
Check whether a string contains exactly one distinct vowel
Over on Stack Overflow, someone asked a simple Haskell question: how to test whether there is exactly one distinct vowel in a given string. To clarify, there can be any number of non-vowel characters, ...
7
votes
3answers
130 views
Prolog parser written in Haskell
I am writing a very simple Prolog intepreter in Haskell. It's a class assignment and I really want to do it right.
I was able to (quite quickly) write a parser for the language. Today I borrowed a ...