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

2
votes
1answer
21 views

Count frequency of characters in a file

Some patterns are emerging ("fmap (b->a) . fmap (c->b) . .. . (IO z)"). Also infix zip is kind-of a hack. What is: Best practice in point-free style? Best ...
1
vote
0answers
17 views

Abstract Key Value Store

I'm attempting to define an abstract interface for a key value store. Some requirements: Once a key has been written it should never be overwritten (although it may be deleted Transactions with ...
4
votes
2answers
27 views

First multi-line Haskell program, extensive use of Maybe type

I'm reading through Write Yourself a Scheme after finishing going through Learn You a Haskell. I attempted one of the early exercises: writing a program to get an operator and two numbers and do a ...
3
votes
1answer
18 views

Update only specific field of specific item (data) in List from YAML

I don't like the logic to update [Repository] list here because I need to map whole list to change only specific field of specific node, I especially don't like ...
4
votes
1answer
49 views

Writing a faster mutable trie

I am implementing a mutable trie. I tested and it produces correct results. However, it is very slow. I benchmark it against plain old Data.Map, which is more than ...
4
votes
1answer
31 views

Safe Reverse Polish Notation

I implemented the following (what I believe to be) safe Reverse Polish Calculator. Now I'm using foldM to take advantage of the power of Monads. Previously, I was ...
2
votes
2answers
35 views

Safely getting the next element of a list

I'm looking for general review and improvements on this code that safely gets the next element of a list (and wraps to the first element if you exceed the list). It just seems a little excessive for ...
3
votes
1answer
29 views

Implementing “Pierre the Tight-rope” Walker from LYAH

Learn You a Haskell presents an excellent introduction to >>= with an example. Basically, Pierre is a tight-rope walker ...
3
votes
1answer
43 views

How can I make this Euler/RK4 implementation more elegant?

One of the things that I'm doing to teach myself is converting some numerical methods from existing Python code (they seem to me to lend themselves to functional programming quite well). I'd like to ...
4
votes
1answer
47 views

A simple database

After failing miserably to get SQL to work with Haskell, I decided to try making my own system. It's fairly simple, but works well for simple jobs (I made it to handle highscores for a number guessing ...
3
votes
1answer
60 views

Random Schedule Generator

In an attempt to try something new, and possibly help out at work, I tried creating a random schedule generator that generates schedules based on 3 inputs (Rotation length, Staff list, and Shift ...
4
votes
1answer
45 views

Using quickCheck for “99 Haskell problems” - problem 1

I'm working on learning Haskell, and I've implemented a solution to the first of the 99 Haskell problems. Here is my code: ...
3
votes
1answer
54 views

Getting the index (x,y) of a char in a “2D” list in Haskell

I have this working function circuitFind that I really don't find nice because I feel there is a better and simpler way to accomplish what it does. ...
2
votes
1answer
47 views

Type dispatch based on runtime value

Suppose we're implementing an interpreter for the bytecode of some stack machine. Let every element of the stack be a Word8, and let the stack be represented by a ...
4
votes
1answer
97 views

Using phantom types to represent amounts and exchange rates of currencies

I posted the following snippet to StackOverflow, and someone said there was much to be improved. ...
4
votes
1answer
67 views

Computation for finding the largest prime factor of 600851475143 is slow

I implemented the following for Project 3 in Project Euler: ...
2
votes
0answers
25 views

Binomial Heap in Haskell

Here's a partial binomial heap implementation in Haskell (just merge and insert): ...
2
votes
0answers
33 views

A solution to the AST Typing Problem

Expression trees are the bread and butter of functional programming but when it comes to adding additional information to an established tree it can be difficult to incorporate such changes without ...
11
votes
2answers
99 views

Calculating Luhn-algorithm checksum digit

Today I decided to learn some basic Haskell, and for starters I made a program for calculating the checksum of a Swedish personal identification number. It uses the Luhn-algorithm, aka. ...
7
votes
1answer
1k views

Update Map in Haskell

I wrote a function that inserts or updates a Map key value depending on whether the key is already in the ...
3
votes
1answer
29 views
7
votes
1answer
38 views

Primitive stack-based code interpreter

I've written an interpreter for a simple assembly-like language and it's performing slower than I would like. It's split into 3 files: the Parser that converts the source to a vector of ints, the VM ...
5
votes
0answers
54 views

Website using Persistent, Blaze-html, and Scotty

I know that my let configFilePath = Prelude.head args is unsafe and was wondering how I could handle it better. My deployment almost always has a file at ...
12
votes
3answers
106 views

Haskell FizzBuzz with a type system

The core problem is simple enough, but I've developed a type system that I'm not sure about. The intention is, if the result is a number, calling ...
4
votes
1answer
70 views

Finding Shortest Path

Working on Functionally Solving Problems from Learn You a Haskell, I worked on the "Heahtrow to London" shortest path problem. I'm working on a reduced set of this problem in order to solve a simple ...
3
votes
1answer
64 views

Haskell idioms in functions/arguments handling

I came up with this function rangedReplace as an exercice to use recursion and try different ways to make it work (I made at least 3 completely different versions). ...
5
votes
1answer
56 views

Reverse Polish Notation Calculator

Working through Learn You a Haskell, I made a Reverse Polish Notation calculator. Please critique it. ...
2
votes
1answer
45 views

Folding with trees

I was trying to implement a foldTree function to generate a balanced binary tree from a list of values using foldr (Question 2 ...
5
votes
0answers
71 views

Thinking in 'Haskell' - when to use (state) Monads

I really enjoy Haskell but feel I still have a total beginner's style, and would like to move beyond that. The code below - for Dijkstra's shortest path algorithm - is a case in point. I feel as ...
5
votes
1answer
62 views

Brute force Caesar Cipher decrypter

I wrote the following that tries to crack a message that was encrypted via a simple Caesar cipher through brute force. I'm fairly new to Haskell, so any and all input is appreciated. Because there are ...
3
votes
1answer
30 views

Simplification of consecutive `map`s

I've written the following code: ...
5
votes
2answers
150 views

Merging time series

Is there a better way to do this? A time series, data Model a where Variant :: [(Day, a)] -> Model a deriving (Show) ... where type ...
5
votes
0answers
51 views

Project Euler Problem 18 (Haskell) - Maximum path sum I

I've implemented the solution to Project Euler Problem 18 in Haskell and I'd like to get some thoughts on my implementation. Its the dynamic programming solution, working from the bottom up. ...
3
votes
1answer
25 views

Implementing `randoms`

Learn You a Haskell presents the randoms function. I implemented it as follows: ...
10
votes
1answer
87 views

Random Coin Toss in Haskell

Learn You a Haskell gives an exercise to implement the following function: ...
3
votes
1answer
45 views

Haskell encryption tips

I wrote a variation of the Caeser Cipher and would like some feedback. Is it idiomatic? Can you generally see anything that can be improved? Use example: ...
3
votes
3answers
35 views

Push List Element to Top

Please evaluate this function. It takes a list [a] and an Int, i.e. the index, and returns a new list with the selected item at ...
2
votes
2answers
40 views

Implementing Todo in Haskell

Per Learn You a Haskell, I implemented a simple command-line program, Todo, that accepts 1 of 3 arguments: view or ...
2
votes
2answers
256 views

Counting occurrences of Char8s in a file

To learn some Data.Map and Control.Monad.State, I have written the following code, which should count the occurrences of ...
8
votes
3answers
82 views

Splitting a list into overlapping sub-lists

I'm very new to Haskell. I did try it for a few days, a few years ago... but other than that, this is my second day. I'm equally unused to functional programming, by the way. After much trial and ...
4
votes
1answer
91 views

Dynamic programming with Project Euler #18

I just wanted to get an opinion on my dynamic-programming Haskell implementation of the solution to Project Euler problem 18. The Problem: By starting at the top of the triangle below and moving ...
4
votes
1answer
99 views

Code from “Write Yourself a Scheme in 48 Hours” tutorial

I recently went through this Haskell tutorial. I'd be interested in any thoughts or comments at all, in terms of improving the structure, order, haskell conventions, or that long, kind of ugly eval ...
2
votes
1answer
37 views

v2 - Adding a duplicate entry randomly into a list in haskell using random monad

Next version of Adding a duplicate entry randomly into a list in haskell using random monad I wrote this trying to set up a Haskell testcase. The aim is to take a list and add a single duplicate from ...
3
votes
2answers
76 views

Haskell Collatz Conjecture

In an attempt to begin properly programming in Haskell, I wrote two functions for calculating numbers and sequences with Collatz's conjecture. I also commented the program quite a lot, because it ...
4
votes
2answers
77 views

Deciding whether a list of sum types is homogeneous

I ran into a problem recently where I had to decide whether a set of sum types was homogeneous (all the same). In itself, this is a pretty simple problem. However, there were a few complicating ...
4
votes
1answer
19 views

Adding a duplicate entry randomly into a list in haskell using random monad

There's a new version of this as v2 - Adding a duplicate entry randomly into a list in haskell using random monad I wrote this trying to set up a Haskell testcase. The aim is to take a list and add ...
1
vote
1answer
40 views

Batch file renamer

Please tell me how I can improve the structure of this simple tool (depends on MissingH): ...
0
votes
3answers
64 views

Function Composition: $ versus `.`

Learn You a Haskell offers the findKey function: Here's the book's implementation: ...
1
vote
1answer
31 views

Substitution Cipher in Haskell

Learn You a Haskell presents the Caesar Cipher: The Caesar cipher is a primitive method of encoding messages by shifting each character in them by a fixed number of positions in the alphabet ...
10
votes
2answers
157 views

Processing text files for data extraction and analysis

I started learning Haskell to see if I can use it at my job. A lot of my work is processing text files for data extraction and analysis. For my first test, I added a counter at the end of each line ...