51,835 questions
0
votes
0
answers
28
views
Making VSCode + stack respect .ghcup/env
I'm using latest VSCode with Haskell extension. There's a trivial (?) problem of toolchain (GHC, HLS, stack, cabal) being mismatched depending on what process is used to start VSCode (Debian + KDE ...
0
votes
1
answer
63
views
Warning "Defaulting the type variable `a0' to type `Integer'"
Code:
module Main where
main :: IO ()
main = topLevel
topLevel = putStrLn $ "Hello World!" ++ (show 3)
Generally on the internet they write that when you want to convert Integer to String ...
1
vote
0
answers
43
views
PrimaryKeyed typeclass for Rel8
Using Haskell's Rel8 library, I am trying to create a typeclass of tables with a primary key, providing a projection of the key in any context. Ideally, it would look something like this:
class ...
Best practices
1
vote
8
replies
129
views
Haskell FunDeps having too much fun
This isn't a what am I doing wrong? Rather, I'm surprised this works, what's the rationale?/might it all quickly turn to custard.
By ‘ambiguous’ we mean that there is a type variable e that appears ...
3
votes
2
answers
137
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
303
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
102
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
110
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
137
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
148
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
211
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
146
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
95
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
107
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 ...