19,248 questions
Score of 1
1 answer
73 views
Kotlin Type Erasure irreversible?
Let's say we have a functional interface for processing annotations (AnnotationProcessor) that takes the annotation class it will work with as a parameter. We then define three of these processors; I'...
Advice
0
votes
2
replies
67
views
String from list's values in functional programming
I'm new to functional programming, and I'm trying to write a function that takes a list (of indeterminate size) of values and return a string of a formatted version of each value.
For instance (in ...
Advice
2
votes
5
replies
111
views
Why do the stronger guarantees of functional programming not yield consistently more optimal code?
Probably too general of a question, but it came to mind after watching a YouTube video of a guy talking about recursion schemes and performance in functional languages when compared to C.
In my mind, ...
Best practices
0
votes
2
replies
58
views
Constructor config vs explicit method parameters for strategy interface: which is better for an order processor API?
I’m designing an API for order batching and would like opinions on one specific design choice.
Context:
An API request gives me only a tenant_id
From tenant_id, I load warehouse_layout
From ...
Best practices
1
vote
8
replies
173
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 ...
Score of 3
2 answers
179 views
Why doesn't GHC automatically add injectivity annotation to closed type families (provided that instances 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
378
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 ...
Score of 2
1 answer
163 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 ...
Score of 3
1 answer
126 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
...
Score of 2
2 answers
161 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 ...
Advice
3
votes
8
replies
240
views
Does V8 optimize curried functions like a typical functional programming language?
Functional programming languages like Haskell or OCaml go though some effort to make
curried functions have reasonable performance compared to uncurried functions. I am curious if V8 has any ...
Score of 5
0 answers
186 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 ...
Score of 6
1 answer
191 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 ...
Score of 1
1 answer
65 views
Implementing Functor for a binary tree in Lean 4
I am following the lean tutorial and I've arrived at the exercise where I have to implement the Functor typeclass for a simple binary tree inductive type.
This is the code for defining the tree type:
...
Score of 4
3 answers
199 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 ...