Haskell is a functional programming language featuring strong static typing, lazy evaluation, extensive parallelism and concurrency support, and unique abstraction capabilities.
Questions tagged [haskell]
77 questions
13
votes
3 answers
Rigorous proof that parametric polymorphism implies naturality using parametricity?
This question asks for an informal explanation of why all polymorphic functions between functors are natural transformations (This is a claim made by Bartosz Milewski). One answer to that question refers to the Theorems for free! paper. However,…
user56834
- 4,244
- 5
- 21
- 35
13
votes
1 answer
Is the IO monad technically incorrect?
On the haskell wiki there is the following example of conditional usage of the IO monad (see here).
when :: Bool -> IO () -> IO ()
when condition action world =
if condition
then action world
else ((), world)
Note that in this…
Lasse
- 233
- 1
- 6
12
votes
1 answer
Monad in Haskell programming vs. Monad in category theory
I have a question about concept of monad used in Haskell programming
and category theory in math.
Recall in Haskell a monad consists of following components:
A type constructor that defines for each underlying type how the
corresponding monad type…
user267839
- 233
- 1
- 6
11
votes
1 answer
Semantics for de Bruijn levels
There is an exceptionally simple way to embed simply typed lambda calculus with de Bruijn indices in a functional host language (discussed by Carette, Kiselyov & Shan, and by Kiselyov). The construction here, expressed in Haskell, is from Kiselyov's…
SEC
- 241
- 1
- 7
9
votes
2 answers
Functor laws and natural transformations in Haskell
As I've been struggling to get a deeper understanding of monads in Haskell, I started reading about functors and their counterparts in category theory. Keep in mind that I have no background in the latter.
According to Milewski(1), any polymorphic…
giofrida
- 195
- 6
8
votes
1 answer
Strictness in both arguments but not in each individually
I'm learning about strict functions in Haskell.
A function f is strict if f ⊥ = ⊥
Some functions are strict only in the first argument (for e.g. const), others are strict in the second (for e.g. map).
I'm trying to think of a function which is…
Marta
- 83
- 4
8
votes
1 answer
What exactly is the relation between Haskell and category theory?
In articles or Quora posts about category theory, I often find mentions of the programming language Haskell. I have little knowledge of category theory and even less of programming. Could someone please explain how category theory is important in…
Clemens Bartholdy
- 281
- 1
- 9
7
votes
1 answer
Curry Howard correspondence to Predicate Logic?
So I'm trying to get my head round Curry-Howard. (I've tried at it several times, it's just not gelling/seems too abstract). To tackle something concrete, I'm working through the couple of Haskell tutorials linked from wikipedia, esp Tim Newsham's.…
AntC
- 527
- 3
- 15
6
votes
1 answer
How to model conditionals with first-class functions?
Since languages with recursible first-class functions are Turing-complete, they should be able to express anything expressible in any other programming language. Therefore, it should be possible to model conditional expressions (i.e. if-statements)…
Shen Zhuoran
- 173
- 4
6
votes
1 answer
Implementing mathematical theory of arithmetic in Haskell via Curry-Howard correspondence
I have to ask for forgiveness in advance if the whole question doesn't
make a lot of sense, but unfortunately, I have no better intuition as
of right now and this seems like the best starting point I could come
up with.
I'm reading Tarski's book…
Kostiantyn Rybnikov
- 163
- 5
6
votes
1 answer
Are there any type constructors which are *not* functors?
So I'm almost done teaching myself category theory. One of the main take-aways for me is that type constructors (higher-kinded types) are endo-functors.
But it this always the case? What's throwing me off is Haskell's Functor typeclass:
class…
gardenhead
- 2,240
- 14
- 19
6
votes
1 answer
Why does higher-order abstract syntax need an inverse to define catamorphisms?
In the introduction to the colorfully-named Boxes Go Bananas: Encoding Higher-Order Abstract Syntax with Parametric Polymorphism, Washburn and Weirich describe a problem in traditional formulations of higher-order abstract syntax (HOAS):
One…
Alexis King
- 304
- 1
- 11
5
votes
1 answer
Can the semantics of a numeric hierarchy be faithfully represented in Haskell?
I am trying to represent a fragment of a number hierarchy using the Haskell concepts of value, type, and type class. I would like the Haskell code to reflect the mathematical semantics $\vdash ((x \in \mathbb{N}) \land (\mathbb{N} \subset…
Patrick Browne
- 339
- 1
- 9
5
votes
1 answer
Book references for combinatory logic as applied in Haskell?
I am looking for book references on combinatory logic. Is there a book focused on how combinatory logic is applied in the context of pure functional languages like Haskell?
I found "Combinators: A Centennial View" by Stephen Wolfram (2021), but it…
Clemens Bartholdy
- 281
- 1
- 9
5
votes
1 answer
How does Bifunctor in Haskell work?
I was reading 'Category Theory for Programmers' by Bartosz Milewski and got really confused by the implementation of bimap in Bifunctor typeclass.
class Bifunctor f where
bimap :: (a -> c) -> (b -> d) -> f a b -> f c d
bimap g h = first g .…
Qiu Haohao
- 53
- 3