Skip to main content

Questions tagged [haskell]

For questions about Haskell's design, or languages which are closely related to Haskell

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 ...
Enlico's user avatar
  • 175
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 ...
Daphne Preston-Kendal's user avatar
-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 ...
Giovanni's user avatar
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. ...
Dannyu NDos's user avatar
  • 1,485
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 ...
NotAlfred's user avatar
  • 145
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) ...
Delfin's user avatar
  • 155
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 ...
Kilian Kilmister's user avatar
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: ...
MaiaVictor's user avatar
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. ...
Michael Homer's user avatar
  • 15.3k
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 ...
Christian Lindig's user avatar
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 ...
Gergely's user avatar
  • 363
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 ...
Alexis King's user avatar
  • 12.7k
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 ...
Bubbler's user avatar
  • 733
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 ...
alephalpha's user avatar
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 ...
Michael Homer's user avatar
  • 15.3k

15 30 50 per page