Questions tagged [haskell]
For questions about Haskell's design, or languages which are closely related to Haskell
10
questions
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. ...
6
votes
5
answers
469
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
2k
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 ...
14
votes
0
answers
360
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 ...
8
votes
2
answers
97
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
252
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
128
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 ...
10
votes
1
answer
94
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 ...
11
votes
5
answers
369
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,...