51,820 questions
4
votes
3
answers
164
views
Are Void and () isomorphic in the presence of laziness?
This question springs from another earlier question of mine: How can a type with all constructors having a field mapped to Void via a type family have any values at all?, because one implication of ...
4
votes
1
answer
122
views
How can a type with all constructors having a field mapped to Void via a type family have any values at all?
I'm studying Trees that grow by Shayan Najd and Simon Peyton Jones to better understand type families, and I'd like some help.
The paper goes that the following data types can be used to model simply-...
3
votes
3
answers
98
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
57
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 ...
1
vote
0
answers
46
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
88
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
112
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
159
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
154
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
118
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
166
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
124
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
73
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
110
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
147
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 #-}
{-# ...