Questions tagged [haskell]

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.

Filter by
Sorted by
Tagged with
3
votes
0answers
87 views

Vocabulary memory game in Haskell

As a beginner I try to implement a vokable memory game. It is still missing some feature (Loading, Display), but I would like to hear how to improve what is already there. The user should identify ...
3
votes
1answer
117 views

Determining whether (x,y) points in the input constitute a function

I'm learning Haskell, and I've finally gotten around to coding up some Haskell. This code passed my tests. This code takes a line from standard in which tells it how many cases it's going to have (1 ...
5
votes
2answers
466 views

A simple queue implementation in Haskell

I'm a member of a discord channel and sometimes people post simple coding exercises for fun. This time the exercise was: Implement the following operations of a queue using stacks. push(x) -- Push ...
10
votes
3answers
1k views

Given a Haskell list, return all sub-lists obtained by removing one element

I am trying to write a Haskell function which takes a list ls and returns all sub-lists obtained by removing one element from ls....
2
votes
1answer
119 views

Implementing foldl1 in Haskell

As an exercise (scroll to the first set of exercises) for learning Haskell, I have to implement foldl1. I believe I have implemented it successfully and while ...
1
vote
1answer
165 views

Expression tree in Haskell with support for differentiation

A simple binary expression tree in Haskell without operator precedence and without parentheses. Any comments would be much appreciated. ...
4
votes
0answers
45 views

Functional blob counting

I have image files consisting of black and white pixels encoded as RGB8. I want to count the number of blobs i.e. contiguous areas of white pixels. I rewrote this algorithm in haskell. The algorithm ...
1
vote
1answer
164 views
2
votes
1answer
87 views

Graham Scan Algorithm in Haskell

I have just begun learning functional programming and Haskell. This is my attempt to implement a solution to Graham Scan Algorithm in Haskell. Note that I am not even sure if this is indeed Graham ...
4
votes
2answers
61 views

Determine whether path A→B→C on a plane constitutes a left or right turn

I have recently started learning functional programming and Haskell. I have encountered this problem: Consider three two-dimensional points a, b, and c. If we look at the angle formed by the line ...
4
votes
1answer
173 views

Maze solver BFS in Haskell

I am really excited that I just wrote my Haskell maze solution in bfs. This is my very first haskell (and I still haven't tried to build a maze in haskell so that maze is hard coded xD) ANY ...
2
votes
1answer
92 views

Haskell/Yesod - Butchering use of MaybeT

The following is some code that is used to provide the frontend with certain parameters when rendering a form. The parameters are conditional based around what data is being changed, ...
4
votes
1answer
39 views

Find labels in string in Haskell

I wrote code that parses a table header string in order to obtain two string tags, one for variable name (like GDP) and another for unit of measurement (like ...
3
votes
2answers
250 views

Caesar Cipher in Haskell, on every other character

I'm learning Haskell, and I tried to do an exercise which it is an implementation of the Caesar Cipher method. The problem asks for cipher a text which it is in lower case and can contain characters ...
3
votes
1answer
132 views

Printing right triangles recursively in Haskell

I've implemented a simple program to print out 4 right triangles oriented in different ways to learn Haskell. I'm sure there are more efficient ways of doing what I have done, and I just want some ...
1
vote
1answer
76 views

Simple calculator that sums numbers

This is a calculator that only sums numbers: ...
3
votes
1answer
95 views

Monoidal tree interview in Haskell

I was working on the following interview question: Given an array of integers, return a new array such that each element at index i of the new array is the ...
2
votes
1answer
43 views

Haskell 'n' layered ANN forward pass

I'm trying to write a simple 'n' layered ANN in haskell for supervised learning, it will eventually have back prop and you'll be able to use it in a step by step fashion through a GUI which will graph ...
2
votes
1answer
84 views

String Calculator kata in Haskell

In order to practice some Haskell, I tried this kata, where the task is to add some numeric inputs that are delimited by commas or newlines. I have the below solution in Haskell which passes my tests,...
7
votes
1answer
200 views

A simple brainf*** interpreter in Haskell

I am very new to Haskell and come from languages like C++, although I do have some experience with Scheme. Here, I wrote a simple brainf*** interpreter, which so far is my largest project. I followed ...
3
votes
1answer
55 views

Simplifying if statement in a StateT monad transformer

While learning the basics of Haskell I decided to challenge myself with seemingly simple task - write a program that would push the user input into a stack if it's not an empty string or pop the value ...
3
votes
2answers
81 views

Conditionally display an Action depending on whether or not a player is connected

Is there a nicer way to write the maybeWhen portion of displayConnectionAction ? I want to conditionally display an ...
6
votes
2answers
109 views

Command line tool, listing video files on a local drive

Explanation I started learning Haskell about a month ago. As an exercise, I recreated a little command line tool, which I had previously written in PowerShell. In the current state, it displays a ...
6
votes
1answer
302 views

Simple Credit card validation

I'm a beginner to Haskell (intermediate in web-dev stuff and JavaScript) and I'm not really sure what I could do better for Homework 1 of CIS194 that I'm taking online. The problem statement is as ...
1
vote
1answer
66 views

Using MySQL with Wai and Warp

I was wondering if below is the correct convention for combining Wai with a Database pool. What I basically do is, create a pool, partially apply a function of type ...
3
votes
1answer
94 views

Efficient Road Network

Intro I've decided to learn haskell, because I've always enjoyed the functional aspect of Python and want to explore other languages that use this concept. I'm still stumbling in the dark most of the ...
4
votes
1answer
150 views

Haskell K-means implementation

The following is a Haskell backend to a K-means visualisation: I have omitted the API code (exists in a separate module), the relevant endpoints simply call ...
1
vote
1answer
51 views

Haskell game server auth: cookie key generate&check

C++ code version (description copied from it) gameKeys id is authentication function of an MMO game server. When someone wants to play with friends, he sends ...
2
votes
2answers
230 views

Bottom up merge sort in Haskell

Although this sort works on Int lists < length million, when the stack overflows, the last clause of the merge function definition looks odd to me, recursing in 2 places. Is there clearer way to ...
3
votes
2answers
2k views

Bubble sort in Haskell

The following code is part of my practice in implementing algorithms in Haskell. I'm aware that bubble sort is a bad choice for sorting sequences in real applications. ...
1
vote
1answer
123 views

Infinite House of Pancakes in Haskell

In order to learn haskell, I wrote a solver for the Infinite House of Pancakes problem. ...
5
votes
2answers
96 views

Determining if a set of 2d vectors is a valid function

My idea was to take in the function and perform a self cross product so that I could check every pair against every other pair. I'm new to Haskell so this solution is probably rough. My question is, ...
2
votes
0answers
136 views

Haskell function to generate prime numbers up to argument [closed]

I made a function to generate a list of prime numbers using list comprehensions. Here it is: ...
3
votes
1answer
109 views

Purely functional brodal heap implementation

I implemented the Brodal heap from Brodal & Osaki 1996: Optimal Purely Functional Priority Queues in haskell. The paper gives an implementation in ML but without higher-kinded types. The goal was ...
6
votes
1answer
640 views

Haskell BigInt addition

I have a function add that adds two lists of integers: add [1, 2] [4, 5, 8] == [4, 7, 0] add [9, 8, 9] [1, 3] == [1, 0, 0, 2] ...
3
votes
1answer
552 views

Solving the Burst Balloon problem using Dynamic Programming

Continuing where I left off previously to solve the problem described here, I've now solved the same using dynamic programming (following Tikhon Jelvis blog on DP). To refresh, the challenge is to ...
2
votes
0answers
118 views

Smith-Waterman algorithm for local sequence alignment with affine gap penalties

The following is a summary from the top of my head so please correct me if I'm wrong. See the Wikipedia article for more. This is about determining the (score / edit distance of the) most similar ...
4
votes
1answer
119 views

Naive implementation of Burst Balloon

As part of learning Haskell, I'm solving few problems, usually solved imperatively. I've come up with a naive solution for the problem described here, which is to find a sequence in which to burst a ...
6
votes
1answer
81 views

TinCan (Esolang) Interpreter in Haskell

Haskell newbie here. Wanted to improve my skills by re-implementing an esolang I designed back in 2011 called TinCan. If there are things that are perhaps badly coded or unclear things due to my ...
5
votes
2answers
90 views

Calculating Maclaurin series for sin(x)

I'm very new to Haskell as was hoping to get some feedback on my code AND I have some specific questions. I've posted code below or you can see it here. I'd welcome ideas on how better to calculate ...
4
votes
0answers
145 views

Implementation of the Hindley-Milner type system (with evaluation, without type inference) as a library for use in compilers

I've written an implementation of the Hindley-Milner type system as a "Core" language for use in writing compilers of typed functional languages. This is meant to be used as a library by compilers of ...
6
votes
1answer
92 views

Dice Arithmetic Puzzle Solver in Haskell

As a learning exercise, I decided to implement an automatic solver for the Sacred Geometry feat from Pathfinder (a TTRPG). The requirements to use the feat are: Roll N six-sided dice, where 1 < ...
2
votes
1answer
258 views

4-Bit Ripple Carry Adder in Haskell

I recently started learning Haskell and had to program a 4 Bit Ripple Carry Adder that worked with tuples of the form type Nibble = (Bool, Bool, Bool, Bool) ...
0
votes
2answers
160 views

CRUD App in Haskell with Servant/Opaleye

I was trying to learn how to use libraries like Opaleye and Servant. I wrote this toy Create/Read/Update/Delete App. ...
3
votes
1answer
249 views

Fibonacci calculator in Haskell

I'm just starting to look into Haskell. I've written a naive Fibonacci implementation, and I've also written a more advanced one that uses tail-call recursion for efficiency. ...
5
votes
1answer
82 views

Number base manipulation in Haskell

I am picking up good Haskell practices! In this instance, I wanted to pick a file which contains a title in the first line and then every line is a string. Each string represents a number in base ...
10
votes
0answers
674 views

Realtime concurrent Haskell MIDI buffer

Problem Background MIDI is a serial representation of control signals to a sound generator. Typically, a noteOn message initiates the attack phase of a sound at a given pitch. The note will ...
1
vote
1answer
94 views

File manipulation with Haskell

I am trying to pick up Haskell! But I feel like my code is a bit painful to write and read. Do you have any pointers on how to improve its readability / style? ...
4
votes
1answer
289 views

Solving Sierpinski Triangle in Haskell

I am a Haskell beginner with a background in C++ and Python. I have been teaching myself Haskell for about half a year on and off and recently I started doing Hackerrank problems to improve my Haskell ...
5
votes
1answer
117 views

Combinatoric problem in Haskell

I am new to functional programming. Just now I solved my first "real world" task using Haskell and now I'm wondering whether I got it "right" and what can be improved. The problem arises from tensor ...