51,819 questions
1
vote
3
answers
32
views
How to avoid the partial function Map.lookup, when the key is known to be in the map?
I have some programs consuming a list with structured items.
The list may contain an item multiple times.
From these items I extract a subcomponent and
collect all these different subcomponents.
With ...
0
votes
1
answer
47
views
How to use a dependency's extra-lib-dirs in stack.yaml
I'm building a package where one of its dependencies requires an external library. So the stack.yaml looks like this:
snapshot: lts-22.44
packages:
- .
- external/PRECiSA/PRECiSA
PRECiSA's build ...
0
votes
0
answers
34
views
HLS "Couldn't match type" / version mismatch on Windows 10 while Cabal builds fine
OK, I keep getting HLS errors even though cabal builds fine.
Environment:
OS: Windows 10 Pro
GHC: 9.6.7
Cabal: 3.12.1.0
I'm on Windows 10 Pro Education, using GHC 9.6.7, and cabal 3.12.1.0
I'm ...
Advice
0
votes
4
replies
84
views
Why does Haskell print in this format?
The following function
shower = show "String"
when it is called I get the output
"\"String\""
How come those backslashes and addition quotation marks?
In contrast:
shower ...
0
votes
1
answer
111
views
Obtaining mutable arrays from immutable
Is it possible to obtain an array with O(1) read and write access (like Haskell's STArray) using a read only array (such as Haskell's Data.Array.Array)?
Or is there a wrapper around pure functions ...
Best practices
0
votes
5
replies
157
views
Is there a better way to get the length of runs in a list in haskell?
module Trial where
import Data.List
getRunCount :: (Ord a, Eq a) => [a] -> [(a, Integer)]
getRunCount lst = getRunCount' (sort lst) []
where getRunCount' :: Eq a => [a] -> [(a, ...
0
votes
1
answer
150
views
HLS running from terminal and getting cabal error on fresh new project
I'm using HLS from terminal with the command haskell-language-server-9.12.2. I'm getting the following error:
Step 4/4: Type checking the files
2025-12-15T23:04:57.109846Z | Info | Cradle path: app/...
2
votes
0
answers
114
views
Stack for Haskell unable to remove files?
I am a beginner Haskell programmer on Windows 11. I am writing a Snakes & Ladders program, and am attempting to set up a Stack environment to work in.
I have been following this guide, as well as ...
2
votes
1
answer
163
views
What is the rank of these 3 functions? And, most importantly, why?
The following questions are in fact exercises 6.3-i, 6.3-ii, 6.3-iii from Thinking with Types
What is the rank of Int -> forall a. a -> a?
What is the rank of (a -> b) -> (forall c. c -&...
Best practices
2
votes
11
replies
122
views
Terminology for a value that has a particular type in Haskell
In English, I might talk about the category or property or type tree, and then refer to specific trees as tree "instances" of the property tree. (In philosophical writing, sometimes it's ...
Best practices
0
votes
2
replies
71
views
How to refer to heterogeneous list of any size?
I want to make a function call with two arguments: function and its arguments. Arguments are provided as heterogeneous list (Data.HList). Function should have a signature matching types of arguments. ...
Best practices
1
vote
2
replies
108
views
How to get a type of parameter from parametrized type?
How could I get a type of parameter from parametrized type? For example, for type T = Maybe String I want to get String, for type T = [Bool] I want to get Bool. It should be a function of T. Thanks in ...
0
votes
2
answers
145
views
Why is this instance overlapping/how to make interacting type classes work together?
I have the following sample code which shows the problem
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# ...
0
votes
1
answer
194
views
How can I map on a list that returns a tuple?
MRE:
MyType = MyDataCtor [MyType] | MyDataCtor2 MyType MyType | ... other cases (none of which require the map operation)
foo :: Type1 -> Type2 -> (Type1, Type2)
For example, for the ...
2
votes
1
answer
81
views
How to make the entire Parsec parsing process fail upon certain conditions?
I'm creating a toy language in Haskell, and using Text.Parsec to parse everything, So far it's worked great, but there's a certain feature that I don't know how to implement:
What I want to implement: ...