Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.haskell > #640
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
|---|---|
| Newsgroups | comp.lang.haskell |
| Subject | Re: Types |
| Date | 2026-04-20 10:32 +0000 |
| Organization | Stefan Ram |
| Message-ID | <types-20260420112337@ram.dialup.fu-berlin.de> (permalink) |
| References | <types-20260419194256@ram.dialup.fu-berlin.de> <87y0ii7iq1.fsf@posteo.de> |
Jonathan Lamothe <jonathan@jlamothe.net> wrote or quoted:
>I'm curious: what did *his* demo look like? Perhaps he was doing
>something with typeclasses?
The man who I referred to is Bartosz Milewski who wrote an
excellent book on Category Theory, it's excellent because it
explains the basic workings of Haskell's monads very clearly
in chapter "Kleisli Categories" of part I.
I only have some minor quibbles. One thing is, he writes
|type Writer a = (a, String)
. . .
|The syntax for pairs is minimal: just two items in
|parentheses, separated by a comma.
. However, in Python, the parentheses are not necessary,
as in
|p = a, str
(p now is a pair of the two values of a and of str).
A syntax that adds parentheses to this is not "minimal".
Admittedly, for the empty tuple, in Python, one needs to
use parentheses; it is written as "()".
Another thing is "types are sets". He writes:
|2.3 What Are Types?
|
|The simplest intuition for types is that they are sets of
|values. The type Bool (remember, concrete types start with a
|capital letter in Haskell) is a two-element set of True and
|False. Type Char is a set of all Unicode characters like a or A.
. . .
|When we declare x to be an Integer:
|
|x :: Integer
|
|we are saying that it's an element of the set of integers.
|Integer in Haskell is an infinite set, and it can be used to
|do arbitrary precision arithmetic. There is also a finite-set
|Int that corresponds to machine type, just like the C++ int.
and
|Because of the bottom, you'll see the category of Haskell
|types and functions referred to as Hask rather than Set.
. . .
|From the pragmatic point of view, it’s okay to ignore
|non-terminating functions and bottoms, and treat Hask as
|bona fide Set.
. So he says that Haskell types are not exactly sets, but
according to him this is because they have the additional
value "bottom" ("_|_"), otherwise they would be sets as I
understand him.
He does not actually wrote a demo for this interpretation,
he just explained it as quoted above.
Still, Bartosz Milewski's excellent 2017 book "Category
Theory for Programmers" is very much recommended!
Back to comp.lang.haskell | Previous | Next — Previous in thread | Next in thread | Find similar
Types ram@zedat.fu-berlin.de (Stefan Ram) - 2026-04-19 18:51 +0000
Re: Types Jonathan Lamothe <jonathan@jlamothe.net> - 2026-04-19 17:17 -0400
Re: Types ram@zedat.fu-berlin.de (Stefan Ram) - 2026-04-20 10:32 +0000
Re: Types Paul Rubin <no.email@nospam.invalid> - 2026-04-20 11:19 -0700
Re: Types ram@zedat.fu-berlin.de (Stefan Ram) - 2026-04-20 19:32 +0000
csiph-web