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.

learn more… | top users | synonyms

-6
votes
2answers
70 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
44 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 ...
23
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
36 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
3answers
118 views

Haskell - Get Nth from end

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
34 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
44 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
46 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
18 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
58 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
56 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
35 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: ...
1
vote
0answers
19 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
32 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
53 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
44 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
103 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
99 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 ...
3
votes
1answer
57 views
2
votes
2answers
50 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 ...
2
votes
2answers
57 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 ...
5
votes
1answer
65 views

Data structure for expression evaluation in Haskell

Program behaviour Hi! New haskeller here. I've made a data structure for mathematical expressions. I want to parse mathematical expressions like ...
5
votes
1answer
54 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
62 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
116 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 ...
4
votes
3answers
65 views

Filtering triangles

I'm playing with Haskell's list comprehensions, tuples, and foldr. The exercise I've given myself is to find all triangles with a perimeter of length 26 in the set ...
9
votes
5answers
243 views

Pizza Hut math problem #1 in Haskell

I'm currently attempting to learn Haskell after a fair history of imperative programming. When I saw the Pizza Hut Pi Day math problems, I thought the first one would be a good candidate for my ...
8
votes
2answers
693 views

Conversion of a simple Python Neural Network to a Haskell implementation

I started with this code and modified and expanded it in Python. As an exercise/challenge to myself I decided to covert the original to Haskell. I either write imperatively or functionally. This is ...
3
votes
1answer
564 views

Memoized Collatz sequence

Here is one of my programs that utilized memoization and array to improve performance and memory usage. The performance seems satisfactory but the memory usage is ridiculous and I can't figure out ...
4
votes
3answers
79 views

Math eval function for Haskell

I recently finished reading Learn you a Haskell for great good!. Even though some topics are a bit over my head (Monads anyone?), I wanted to try my hand at a ...
2
votes
0answers
31 views

Code Generation with Template Haskell

Background: Recently, I've been working through Coroutining Folds with Hyperfunctions. Don't bail out now if the whole thing makes little sense - it's just the motivation for the existence of my ...
1
vote
1answer
48 views

Mapping and sorting lists of Haskell tuples

I'm a newbie with Haskell and I'm trying to learn the language and its idioms while working through a small data analysis project. The first step of my analysis is to take a very long list of data, ...
2
votes
2answers
101 views

Fizz Buzz in Haskell

Pretty straightforward, I implemented the popular fizz buzz challenge in Haskell. ...
4
votes
2answers
70 views

Convert oOo to Brainfuck and vice-versa

This program was inspired by a Code Golf challenge that I wanted to do properly. It simply converts oOo to Brainfuck and vice-versa. The oOo language basically uses UPPER / lower case information in ...
1
vote
1answer
24 views

Haskell union list implementation pt 2

This is my revision from another post ...
3
votes
1answer
57 views

List union implementation

I'm trying to implement union from the standard Data.List library. I know it's reinventing the wheel, but reimplementing ...
2
votes
1answer
69 views

List of tuples generated through list comprehension

The function returns a list of tuples which is generated through list comprehension: ...
1
vote
0answers
29 views

Expression parser in Haskell using operator precedence table

This is my first non-trivial Haskell project, an expression parser implemented using the Pratt Parser's technique for managing precedence as a layer on top of Parsec. It simply builds an expression ...
3
votes
1answer
58 views

Updates list in haskell to remove duplication

The task in question allows a user to re-rate a film such that only the latest rating from the user should remain in the database. Initially I solved this problem in a very basic manor? This was my ...
4
votes
2answers
93 views

Walking a directory in Haskell

I wrote a function that recursively walks a given directory. ...
4
votes
0answers
45 views

Roman numerals in Haskell

I have written a module that provides some functions for dealing with Roman numerals. I would like some feedback concerning my style, potential performance or elegance improvements, and any ...
3
votes
2answers
48 views

A function determining intervals of values greater than threshold

I wonder if there exists a shorter/more elegant functional programming way than listing all the possible cases. Here, a function that determines positions of beginning/end of subintervals greater than ...
3
votes
3answers
53 views

In a list of pairs, replace snds with median of all snds with the same fst

Given is a list of pairs. I want to replace the second element of all pairs with the median of the second elements of all pairs with the same first element. For example: ...
5
votes
0answers
30 views

Manual instantiations of common typeclasses for a machine word data type

I've written a data type to represent a word in the memory of a MIX computer. A MIX word has a sign bit and five six-bit bytes. So I created a data type and provided instances for all the common ...
2
votes
1answer
67 views

Returning the common divisors of two integers

I have written this function that returns the common divisors of two integers. When called recursively 10 times with big integers ranging in 100000000, it takes over 5 seconds. How can I improve it so ...
4
votes
0answers
56 views

Multiple base numbers parser

This code is a Parser that parses numbers according to R5RS. #b1001 - binary #o2127 - octal #h02d - hexadecimal #d1231 - decimal 3923 - decimal It is ...
5
votes
1answer
104 views

CIS194: Risk!-style “battles”

After reading LYAH and using RWH as a reference, I've been doing the exercises from CIS194, which is often suggested to beginners on irc://freenode.net/#haskell and ...
4
votes
3answers
47 views

Finding heaviest path through triangle

I am doing Project Euler problem 67 which involves finding the heaviest path through a triangle of integers like this one (this is a smaller version from an earlier problem) ...
2
votes
1answer
47 views

Haskell zmq & protobuf message forwarding

I wrote a test program (and first "real" Haskell program!) that receives a zmq request on 1 socket, and forwards part of that message to another socket. There are a 2 things I specifically don't ...
4
votes
1answer
60 views

soundex implementation

The soundex algorithm maps several spellings of a name to a 4 character term. (hopefully mapping all different transcriptions to the same term) The steps as described in Introduction to information ...