Skip to main content

Questions tagged [haskell]

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

Filter by
Sorted by
Tagged with
8 votes
0 answers
256 views

What are some of the challenges in implementing, and disadvantages of having, dependent types in a programming language?

I know about some of the potential advantages and the desirable features of Agda/Coq/F*/Idris2, etc. But what about the other side of things? For example, there seems to have been talk for years about ...
Municipal-Chinook-7's user avatar
2 votes
1 answer
255 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
6 votes
1 answer
165 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
336 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
  • 159
7 votes
1 answer
402 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
29 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
  • 13.6k
9 votes
5 answers
993 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
3k 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
807 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
  • 10.4k
10 votes
3 answers
245 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
520 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
243 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
  • 13.6k
10 votes
1 answer
186 views

Static or dynamic dispatch for parametric polymorphism

I read that, in GHC: Type classes are implemented using a type-directed implicit parameter-passing mechanism. Each constraint on a type is treated as a parameter containing a dictionary of the ...
pxeger's user avatar
  • 848
12 votes
5 answers
440 views

What are the advantages of having first-class functions versus having only anonymous class with fancy sugars?

In Java, there are "SAM-interfaces" which are used as "types" for lambda expressions. In Haskell, there are dedicated types for functions. In Rust, there are no types for functions,...
ice1000's user avatar
  • 2,694