Questions tagged [haskell]

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

Filter by
Sorted by
Tagged with
3 votes
1 answer
218 views

Effective Tail Call Optimization in Non strict functional languages

In functional programing languages is normal optimize forms like factorial n = go n 1 where go 0 acc = acc go n acc = go (n - 1) (acc * n) to ...
6 votes
1 answer
320 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 ...
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: ...
9 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. ...
7 votes
5 answers
581 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 ...
19 votes
2 answers
3k views

Why do they use bind in Haskell over 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 ...
11 votes
5 answers
391 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,...
7 votes
3 answers
343 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 ...
14 votes
0 answers
426 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 ...
4 votes
1 answer
149 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 ...
8 votes
2 answers
109 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 ...
10 votes
1 answer
104 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 ...