Questions tagged [haskell]
For questions about Haskell's design, or languages which are closely related to Haskell
17 questions
7
votes
3
answers
1k
views
What aspects of a language design make copyability of an object possible or conditional to something?
I was reviewing the so-called prototype pattern, and I feel like in C++ it all boils down to "how do I define a virtual copy constructor" (and if you ...
9
votes
1
answer
377
views
What is the problem with bidirectional views?
In his original paper on Views for Pattern Matching, Philip Wadler describes them as bidirectional: the definition of a view had both in and ...
-2
votes
1
answer
412
views
Are functional programming languages (such as Haskell, F#, Scala, & OCaml) memory safe like Rust? What about their embedded domain-specific languages?
Are functional programming languages (such as Haskell, F#, Scala, and OCaml) memory safe like Rust? What about their embedded domain-specific languages (DSLs)?
I am not interested in discussion of ...
2
votes
1
answer
281
views
Is it practical to use binary trees as a sequential container?
Contiguous arrays do not mix with lazy evaluation. That's why Haskell doesn't have contiguous arrays as a primitive type, and why even GHC has a poor API for them. As such, I sought for a workaround.
...
6
votes
1
answer
203
views
What to do with subroutine calls when translating Abstract Syntax Tree to Control Flow Graph?
A newbie here! I'm implementing my current compiler in Haskell and at the moment I'm trying to do the translation of AST to Basic Blocks. Based on the book "Advanced Compiler Design and ...
4
votes
1
answer
380
views
Effective Tail Call Optimization in Non strict functional languages
In functional programing languages it is normal to optimize forms like
factorial n = go n 1
where
go 0 acc = acc
go n acc = go (n - 1) (acc * n)
...
7
votes
1
answer
460
views
How to design interfaces to mimic haskell-like type classes in an object oriented language?
A problem I sometimes run into when using a language like TypeScript or C# is
how they lack a perfect analogue to Haskell's typeclasses. Let's use
Haskell's Functor ...
30
votes
5
answers
5k
views
Are there Haskell-like languages where equations allow for arbitrary left-hand sides?
In Haskell, you can define algorithms by equations that pattern-match on left-hand side constructors. For example:
...
10
votes
1
answer
2k
views
Why can you implement a Monoid type in Java or C#, but not Monad or Functor?
Haskell and some other functional languages have Monad and Monoid types (and Semigroup, Functor, Applicative, and many others), and lists, trees, Maybe, and other types subtype all or some of these. ...
9
votes
5
answers
1k
views
Declaring infix operators like Haskell's in other languages?
Haskell has support for declaring custom infix operators, including their precedence and associativity. In addition, any identifier can be used as binary infix operator by placing it between ...
23
votes
3
answers
4k
views
Why does Haskell use the bind operation instead of Kleisli composition?
In monads, Kleisli composition has the type
infix oK: ('b -> 'c monad) -> ('a -> 'b monad) -> ('a -> 'c monad)
and it satisfies the nice algebraic ...
20
votes
1
answer
1k
views
What is the relationship between STG and RVSDG?
GHC is an optimizing Haskell compiler. Since Haskell is lazy and mutation is rare, control flow and data flow are often very closely aligned. Therefore, it is often most useful to think about ...
10
votes
3
answers
315
views
Semantics of Haskell's `seq`
The section "The seq Function" on https://serokell.io/blog/haskell-to-core mentions that
The seq function, which ...
7
votes
3
answers
624
views
Pros and cons of supporting "or patterns" in pattern matching
In some languages that support pattern matching, there is a feature that allows you to match against multiple patterns at once. This is called "or patterns" in Python 3.10. For example, you ...
4
votes
1
answer
334
views
How do I create an internal DSL with Haskell's do notation?
Haskell has a do notation for writing code that executes in a monad. I've seen that this is sometimes (ab?)used for creating embedded internal domain-specific ...