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
1 answer
50 views

Rendering a cross in ASCII art

I've recently tried to write my functions by using composition. But this one, renderCross' is especially difficult to convert fully. How would I write this ...
user avatar
1 vote
1 answer
32 views

Hangman game in Haskell, written using a state monad

I recently made a simple hangman game in Haskell but soon wanted to explore the state monad, since it could possibly simplify the code. The result was this (see below), which is exactly 30% more lines ...
user avatar
2 votes
1 answer
60 views

A simple hangman game in Haskell

I just finished a course of functional programming in uni and continued to study Haskell because I found it very interesting! I made a simple hangman game and would like to hear any of your thoughts ...
user avatar
6 votes
2 answers
561 views

Simple number-guessing game in Haskell

I've been learning Haskell for 2 weeks now which is I'm very new to it. I would like to have feedback on what is good/bad about my code and how it could I improve in learning functional programming ...
user avatar
  • 63
2 votes
1 answer
37 views

Simple Manual Lexer in Haskell

As a beginner exercise, I made small manual lexer that recognizes three types of inputs: integers: /[-]?[0-9]+/ strings, inside double quotes, with backslash ...
user avatar
3 votes
2 answers
88 views

Generic splitting in Haskell

I am new to Haskell and took it upon myself to make a simple generic list-splitting (e.g. string-splitting) function: ...
user avatar
0 votes
1 answer
48 views

Haskell solution to Day 2 problem of Advent of Code '21

I won't restate the problem in full, but in a nutshell you have to parse a file with a "direction" and a "magnitude", for instance: ...
user avatar
  • 199
4 votes
1 answer
153 views

Haskell: implementing Read for a custom dynamic value type

I'm using Haskell to interpret a dynamically-typed language. I have a sum type called Value which can represent some basic objects: ...
user avatar
  • 143
3 votes
1 answer
60 views

Function to sum all Armstrong numbers within a range

I've tried to solve a challenge posted on a LinkedIn forum using Haskell - a language I'm still learning the basics of - and, while the code works correctly, I would like to get some feedback on the ...
user avatar
  • 199
1 vote
1 answer
62 views

Manacher Algorithm in Haskell

Please review the manacher algorithm in haskell. Find the longest Palindrome in a String. ...
user avatar
  • 237
5 votes
1 answer
79 views

Validate Finnish IBANs

I am currently studying an online course in Haskell and there are no "model examples" of the assignments after finishing them. I'm slowly getting the hang of this, but I'd like some feedback ...
user avatar
  • 87
2 votes
1 answer
57 views

Advent of Code 2021 Day 4

Here is my attempt at Advent of Code Day 4 using Haskell. A file contains list of number in first line. And subsequent lines have the bingo Cards ...
user avatar
  • 237
1 vote
0 answers
53 views

Haskell proof checker for FOL with equality

Is this a correct implementation in Haskell of a proof checker for first order logic with equality? I am most interested in if it is correct, and if the functions can be made clearer. I would like it ...
user avatar
2 votes
1 answer
78 views

AdventofCode 2021: Day 3 Solution

I am beginner to Haskell. Here is my solution to Advent of Code 2021 Day 3. Let me know what you think. I was looking at the transpose function and decided not to use head & tail function. Given ...
user avatar
  • 237
1 vote
1 answer
60 views

Haskell Twitter Thread Follower

I'm learning Haskell and even though I have experience with Functional Programming the Typesystem has been a challenge. I did this yesterday (after like 2 days) and I would like to know whether this ...
user avatar
  • 147
5 votes
1 answer
120 views

Number to Text converter in Haskell

I've written this code in Haskell to convert a number into its written form. It feels ok but at the same time I feel like it can probably be improved on a lot. I would appreciate help in improving it. ...
user avatar
3 votes
1 answer
100 views

Efficiently calculating perfect powers in Haskell

I'm trying to calculate perfect powers to solve this code wars challenge: https://www.codewars.com/kata/55f4e56315a375c1ed000159/haskell The number 81 has a special property, a certain power of the ...
user avatar
3 votes
0 answers
161 views

Advent of Code 2021, Day 3 in Haskell

This is a working solution to today's Advent of Code puzzle, written in Haskell. However, I feel like this solution is not optimal. ...
user avatar
  • 131
8 votes
1 answer
442 views

Haskell Tic-Tac-Toe (with automation and GUI)

There are already many Tic Tac Toe posts. But as far as I can tell, none of the ones in Haskell are complete with a GUI Here is my implementation with Gloss. Gist Link for convenience ...
user avatar
4 votes
1 answer
354 views

Generate possible combinations by range and length

I am learning Haskell and I implemented a recursive function that generates possible strings by length and array (e.g. ['a'..'z']): ...
user avatar
4 votes
1 answer
372 views

Is there a better way to apply a filter over an Either right value?

Suppose you have an IO (Either String (String, [Int])) and you want to filter the [Int]. Let's say we want to use the following ...
user avatar
  • 207
4 votes
1 answer
468 views

Reading a CSV file using Haskell

I'm reading a CSV using Haskell. I'm not sure if this is the appropriate way to do it. This is what I'm doing: Read rows from a CSV -> return lazy byte string Parse the headers and rows from the ...
user avatar
  • 207
1 vote
3 answers
73 views

Word frequency finder

Challenge: find the top three most frequently used words in a string. Only imports from the base package are allowed (source: codewars) I'm looking for feedback on (...
user avatar
  • 155
5 votes
1 answer
102 views

Small combinator parsing library in Haskell

I recently wrote code to parse lambda expressions written in a lisp like format, using a small hand-rolled parsing library. The goal This code was written as a part of this code-golf challenge not as ...
user avatar
1 vote
1 answer
91 views

Finding the argmaximum of a list in Haskell

I've been doing project euler problems in Haskell, and often I've found the need to get the value that gives the maximum of a function. For example, ...
user avatar
4 votes
1 answer
186 views

Breadth first search on trees in Haskell

I'm writing a breadth first search algorithm in Haskell that supports pruning. It is guaranteed that the search will never encounter nodes that have been visited before, so I implemented the search as ...
user avatar
  • 141
4 votes
1 answer
271 views

Minesweeper in haskell

I have recently been learning Haskell, and wrote a minesweeper project as an exercise. Here is link to the project. Basically the code is separated into two parts, the pure part (no monads) and impure ...
user avatar
  • 43
1 vote
1 answer
45 views

Build a fixed-length vector from a recursive factory function

I need a function of type forall (n :: Nat). RandomGen q => q -> Vec n q. Obviously this is possible to do (correctly, don't just ...
user avatar
1 vote
1 answer
46 views

Suggestions on making this parsing/unparsing format more human-friendly

I am working on some application which involves regular expressions with counting. Also, these regular expressions are not necessarily over some fixed alphabet, but over some class of predicates over ...
user avatar
4 votes
1 answer
159 views

Haskell - Convert an Image to Ascii Art

I'm currently learning haskell, and I wanted a simple project to get started. This project uses the JuicyPixels package to handle image reading. The logic of the image to ascii art algorithm is quite ...
user avatar
  • 155
3 votes
2 answers
296 views

Parsing custom text file using haskell

I am working on writing code for find difference between two text files that should be ideally same. the format of file is ...
user avatar
1 vote
1 answer
64 views

State monad and pattern matching on data constructors

I am writing a Settlers of Catan server in Haskell for fun. Currently I am passing around state manually. I want to learn more about the State monad and want to incorporate it into my project. However,...
user avatar
3 votes
2 answers
265 views

Haskell Function to get the List representation of an Integral

This is a simple practice problem. The task is to write a function getLR that receives an Integral, ...
user avatar
1 vote
1 answer
53 views

Find circles for `f(z, c) = z ^ 2 + c` of length 6 in rational numbers

I've found pretty simple problem on Numberphiles channel: suppose we have a recursive function $$ \begin{equation} \begin{split} f_0 &= Z ^ 2+ C \\ f_i &= f_{i-1}^2 + C \; | \; i = 1 \dots \...
user avatar
  • 1,729
1 vote
1 answer
43 views

Equivalent partition sums

I'm looking for feedback on my solution to the following prompt: Given an array of ints, return the index such that the sum of the elements to the right of that index equals the sum of the elements ...
user avatar
  • 155
1 vote
1 answer
88 views

Fuzzy Finding in Haskell

In learning haskell, I'm writing a fuzzy menu. At the moment, my executable reads in a 'dictionary' from stdin, and ranks each word according to how well it fuzzily matches a search pattern given in ...
user avatar
  • 169
1 vote
0 answers
41 views

Count number of days within each date range in a list of date ranges

Happily picked up Haskell a couple days back and working on the following use case. Given a list of JSON objects with date fields and a start date, I want to create a list of weeks (here a tuple of ...
user avatar
3 votes
1 answer
72 views

Haskell implementation of Needleman-Wunsch

The code below is a Haskell implementation of Needleman-Wunsch algorithm for sequence alignment (and string edit distance). It's an experiment in trying to closely imitate the dynamic programming ...
user avatar
  • 33
6 votes
2 answers
1k views

Hamming distance between two strings

I wrote this module to find the Hamming distance between two strings. (It's a problem from exercism.io's Haskell track.) As I saw it, the problem has two distinct ...
user avatar
2 votes
2 answers
173 views

How can I make a shorter binary rule in haskell?

Here is a code I experimented with recently: let br = [0]:[n:(concat $ take n br) | n <- [1..]] in concat br This code produces the binary rule ...
user avatar
  • 131
1 vote
1 answer
42 views

Haskell program with basic CLI parsing, file reading, and decoding file contents into specified types

I recently completed the following exercise, but wanted some feedback on how idiomatic etc. my haskell program is. This is from a course which introduces us to file IO before we cover the theory of ...
user avatar
3 votes
2 answers
46 views

Insert value into multiple locations in a list

Code ...
user avatar
  • 155
5 votes
1 answer
180 views

Linear Regression in Haskell

After quite some time away from Haskell I am trying to brush up. To do so I am writing some basic linear regression functionality. The code produces the output expected. In essence I am trying to ...
user avatar
1 vote
1 answer
70 views

Generating the N-bonacci numbers

I'm new to Haskell, and this is one of the more interesting programs I've made with it so far. I understand there are already solutions to this problem that use much less code, but to me this one ...
user avatar
0 votes
1 answer
76 views

Sum of fractions

Objective: Create a function to sum a list of fractions (represented as pairs) Rules Only Prelude functions allowed Notes I was debating if I should create a ...
user avatar
  • 155
7 votes
1 answer
216 views

A beginner's brainfuck interpreter in Haskell

I am rather new to haskell, and could use some feedback on my code and the decisions I had to make. In my previous project, I made a JSON parser, but relied heavily on guidance from a university ...
user avatar
0 votes
1 answer
167 views

Pairwise summation in Haskell, take two

Here's my second try at pairwise summation in Haskell: ...
user avatar
2 votes
1 answer
182 views

Pairwise summation in Haskell

I'm new to Haskell, and I figured that pairwise summation is something I could do easily. I wrote this: ...
user avatar
1 vote
1 answer
72 views

Changing an element in a list when a predicate holds

My current project is a Settlers of Catan server in Haskell. I often manage to achieve my goals within Haskell, but the code is getting messier as the project grows. My question is about the ...
user avatar
1 vote
1 answer
61 views

Unique elements, long runtime Haskell

I have two functions. Both have to have unique elements, one with Integers and the other a String which returns a list of ...
user avatar
  • 135

1
2 3 4 5
22