Skip to content

Commit aadda79

Browse files
committed
algebras => records of functions
1 parent 6b4c5fb commit aadda79

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

manuscript/backmatter.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -579,15 +579,17 @@ topic, but it is easy to derive a typeclass for an ADT:
579579
~~~~~~~~
580580

581581

582-
## Algebras
582+
## Records of Functions
583583

584584
In Scala, typeclasses and algebras are both defined as a `trait` interface.
585585
Typeclasses are injected by the `implicit` feature and algebras are passed as
586586
explicit parameters. There is no language-level support in Haskell for algebras:
587587
they are just data!
588588

589-
Consider the simple `Console` algebra from the introduction. We can rewrite it
590-
into Haskell as a *record of functions*:
589+
A> *Algebra* is the somewhat confused Scala name for this concept: in Haskell it's
590+
A> called a *record of functions*. Because it's just a record. Of functions.
591+
592+
Consider `Console` from the introduction. We can rewrite it into Haskell:
591593

592594
{lang="text"}
593595
~~~~~~~~
@@ -632,9 +634,9 @@ more boilerplate but makes the code easier to read:
632634
~~~~~~~~
633635

634636
Whereas in Scala this encoding may be called *Finally Tagless*, in Haskell it is
635-
known as MTL style. Without going into details, some Scala developers didn't
636-
understand a research paper about the performance benefits of [Generalised ADTs
637-
in Haskell](http://okmij.org/ftp/tagless-final/index.html#tagless-final).
637+
known as *MTL style with records of functions*. Without going into details, some
638+
Scala developers didn't understand a research paper about the performance
639+
benefits of [Generalised ADTs in Haskell](http://okmij.org/ftp/tagless-final/index.html#tagless-final).
638640

639641
An alternative to MTL style are *Extensible Effects*, also known as [Free Monad
640642
style](http://okmij.org/ftp/Haskell/extensible/more.pdf).

manuscript/book.org

+10-6
Original file line numberDiff line numberDiff line change
@@ -16978,15 +16978,19 @@ data List a = Nil | a :. List a
1697816978
deriving (Eq, Ord)
1697916979
#+END_SRC
1698016980

16981-
*** Algebras
16981+
*** Records of Functions
1698216982

1698316983
In Scala, typeclasses and algebras are both defined as a =trait= interface.
1698416984
Typeclasses are injected by the =implicit= feature and algebras are passed as
1698516985
explicit parameters. There is no language-level support in Haskell for algebras:
1698616986
they are just data!
1698716987

16988-
Consider the simple =Console= algebra from the introduction. We can rewrite it
16989-
into Haskell as a /record of functions/:
16988+
#+BEGIN_ASIDE
16989+
/Algebra/ is the somewhat confused Scala name for this concept: in Haskell it's
16990+
called a /record of functions/. Because it's just a record. Of functions.
16991+
#+END_ASIDE
16992+
16993+
Consider =Console= from the introduction. We can rewrite it into Haskell:
1699016994

1699116995
#+BEGIN_SRC haskell
1699216996
data Console m = Console
@@ -17027,9 +17031,9 @@ echo Console{readln, println} = do line <- readln
1702717031
#+END_SRC
1702817032

1702917033
Whereas in Scala this encoding may be called /Finally Tagless/, in Haskell it is
17030-
known as MTL style. Without going into details, some Scala developers didn't
17031-
understand a research paper about the performance benefits of [[http://okmij.org/ftp/tagless-final/index.html#tagless-final][Generalised ADTs
17032-
in Haskell]].
17034+
known as /MTL style with records of functions/. Without going into details, some
17035+
Scala developers didn't understand a research paper about the performance
17036+
benefits of [[http://okmij.org/ftp/tagless-final/index.html#tagless-final][Generalised ADTs in Haskell]].
1703317037

1703417038
An alternative to MTL style are /Extensible Effects/, also known as [[http://okmij.org/ftp/Haskell/extensible/more.pdf][Free Monad
1703517039
style]].

0 commit comments

Comments
 (0)