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

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

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

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

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

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

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

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

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

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

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

Semantics of Haskell's `seq`

The section "The seq Function" on mentions that The seq function, which ...
10 votes
1 answer

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 ...