51,831 questions
3
votes
2
answers
124
views
Why doesn't GHC automatically add injectivity annotation to closed type families (provided that insntances don't conflict with it)?
Since closed type families have all their clauses appearing together and therefore can't be extended with other clauses, and since GHC can detect violations of injectivity annotations anyway (even for ...
Advice
1
vote
16
replies
284
views
what's a good functional language for someone coming from perl?
We're avid Perl programmers but we have been really wanting to get into Haskell or Erlang or something similar, though we don't know where to start. Any languages you guys recommend? if so, send some ...
1
vote
1
answer
95
views
What is the grammar of GADTs and ADTs in GHC2024?
My question comes for the fact that I don't fully understand the nuances of declaring datatypes. I think I get lost in all the degrees of freedom out there: do I use GADT syntax or not? Do I spell out ...
3
votes
1
answer
107
views
Why explicitly writing a singleton ctor - instead of just _ - is necessary in the context of dependent types?
Section §13.2 from Haskell in Depth is about "faking" dependent types in Haskell via singletons.
Below is one snippet of code from that section:
doorState :: forall s. Door s -> DoorState
...
Best practices
0
votes
18
replies
169
views
Looking for a term of art ("pseudo-phantom type"?) in typeful programming
Typically typeful programming uses Proxy to signal to the reader this is used for its type, not its value. Indeed there might not be any usable value/it's typically undefined. Here's a previous q ...
2
votes
1
answer
122
views
Halving a list with lazy evaluation
I have the following function which splits a list in half:
halve :: [a] -> ([a], [a])
halve xs =
go xs xs
where
go (x : xs) (_ : _ : ys) =
mapFst (x :) $ go xs ys
go xs _ =
(...
-2
votes
1
answer
145
views
Optimization of entropy-based wordle solver on haskell [closed]
My wordle solver seems to be slow, i would like to ask your opinions on how i can speed it up further
I did some optimizations i could think of, but speed still seems to be bad
As far as i understand, ...
4
votes
0
answers
200
views
How can I apply tail/tails to a string of text in a Unicode-aware manner?
This "warning sign" character, ⚠️, corresponds to the sequence of codepoints U+26A0 U+FE0F (if I understand correctly, it is ⚠ followed by a variation selector character), so I can render it ...
2
votes
2
answers
140
views
Is there a feature (pattern synonyms?) to turn a datatype into syntactic sugar for constructing another datatype?
Say I define this datatype in my library
data Foo = Foo (String, String, String, String)
and that I expose a bunch of things do use it, but that the client really only needs to construct a Foo and ...
Best practices
0
votes
7
replies
93
views
How to filter a length-indexed list (GADT)
Assuming a length-indexed list/GADT as per this recent Q:
{-# LANGUAGE GADTs, DataKinds, KindSignatures #-}
data Vec a (n :: Nat) where
Nil :: Vec a Zero
Cons :: a -> Vec a n -> Vec a (...
2
votes
1
answer
105
views
How do I recover Haskell Stack's ghcup integration after deleting the global stack config?
I used ghcup to install the Haskell build tool "stack".
When setting up ghcup, it gives you an option to configure stack to use ghcup to manage ghc versions, this is handy because it makes ...
5
votes
0
answers
159
views
What is generativity of Type->Type functions?
tl;dr (hopefully)
While writing the question below, I think I've come up with a simpler way to ask it.
Assume this senario:
you've never seen Maybe in Haskell before, so you don't know it's ...
6
votes
1
answer
175
views
Are GADTs only syntactic sugar?
tl;dr
Is it always possible to desugar a GADT data type into an "ordinary" data type?
(Similar question from 2018, but the ansewer (same age) doesn't address the general case, and the ...
3
votes
3
answers
170
views
Compose const with itself n times
I have manually defined the following Haskell functions:
--disregardNextZero x = x
disregardNextZero = id
--disregardNextOne _ x = x
disregardNextOne = const id
--disregardNextTwo _ _ x = x
...
4
votes
3
answers
191
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 ...