Book #25 - Haskell in Depth

Haskell in Depth
by Vitaly Bragilevsky (2021)

 

Meetup: https://www.meetup.com/the-south-padre-island-reading-group/events/291151890/
Zoom: https://us02web.zoom.us/j/84281187589
Discord: https://bit.ly/35RhGXM
Manning: https://www.manning.com/books/haskell-in-depth
Source code (zip): https://www.manning.com/downloads/1929
Source code (github): https://github.com/bravit/hid-examples

 

Chapter 16
Concurrency

January 23, 2023
February 6, 2023

Presenter

Chapter 16
Concurrency

January 23, 2023
February 6, 2023

Presenter

16.1.1 An implementation of concurrency in GHC

Casey - January 23

16.1.2 Low-level concurrency with threads

Jens - January 23

16.1.3 High-level concurrency with the async package

Sergey - January 23

16.2.1 Synchronization and communication
part 1: MVars and operations over them

Casey

 

16.2.1 part 2: Channels
Potential deadlocks with MVars

Weining

16.2.2 Software transactional memory
part 1: STM transactional variables and STM transactions

Sergey

16.2.2 part 2: STM queues and channels

Jens

 

Chapter 15
Working with relational databases

December 12, 2022
January 9, 2023

Presenter

Chapter 15
Working with relational databases

December 12, 2022
January 9, 2023

Presenter

15.1 Setting up an example

Casey - December 12

15.2 Haskell database connectivity

Weining - December 12

15.3 The postgresql-simple library

Jens - December 12

15.4 The hasql ecosystem

Jens - January 9

15.5 Generating SQL with opaleye

Jens - January 9

 

Chapter 14
Data-processing pipelines

October 17, 2022
October 30, 2022 (Sunday!)
November 14, 2022
November 28, 2022

Presenter

Chapter 14
Data-processing pipelines

October 17, 2022
October 30, 2022 (Sunday!)
November 14, 2022
November 28, 2022

Presenter

14.1 Streaming data
14.1.1 General components and naive implementation
- What’s a stream?
- Generalizing elements to functorial steps

Casey - October 17

14.1.1 (part 2)
- Stream as a monad
- Stream as a free monad

Jens - October 30

14.1.1 (part 3)
- Implementing functor general functions
- Stream as a result and a functorial step

Weining - October 30

14.1.2 The streaming package
- Example: Tabulating numbers with sums
- Introducing the streaming package

Jens - October 30

14.1.2 (part 2)
- Lists/streams analogy in types
- Simple streaming functions

Omar - October 30

14.1.2 (part 3)
- To copy or not to copy
- Example: demonstrating s.copy behavior

Casey - November 14

14.2 Approaching an Implementation of pipeline stages
14.2.1 Reading and writing data efficiently

Sergey - November 14

14.2.2 Parsing data with parser combinators

Jens - November 14

14.2.3 Accessing data with lenses

Sergey - November 14

14.3 Example: Processing COVID-19 data
14.3.1 The Task

Jens - November 28

14.3.2 Processing data

Jens - November 28

14.3.3 Organizing the data

Jens - November 28

 

Chapter 13
More about types

September 5, 2022
September 19, 2022
October 17, 2022

Presenter

Chapter 13
More about types

September 5, 2022
September 19, 2022
October 17, 2022

Presenter

13.1 Types for presenting a web API
13.1.1 Implementing a web API from scratch

Casey - Sep 5

13.1.2 Implementing a web service with servant

Sergey- Sep 19

13.2 Towards dependent types with singletons
13.2.1 Safety in Haskell programs

Weining - Sep 19

13.2.2 Example: Unsafe interface for elevators

Weining - Sep 19

13.2.3 Dependent types and substituting them with singletons

Jens - Sep 19

Discussion of code examples involving Servant

Omar - pending

Discussion of paper “Propositions as Types” by Philip Wader

Jens - pending

13.2.4 Example: Safe interface for elevators

Jens - pending

 

Chapter 12
Metaprogramming in Haskell

July 27, 2022
August 3, 2022
August 17, 2022

Presenter

Chapter 12
Metaprogramming in Haskell

July 27, 2022
August 3, 2022
August 17, 2022

Presenter

12.1 Deriving Instances
12.1.1 Basic deriving strategies

Casey - July 27

12.1.2 The problem of type safety and generalized newtype deriving

Jens - July 27

12.1.3 Deriving by an example with DerivingVia

Weining - July 27

Deriving Via by Baldur Blöndal, Andres Löh, and Ryan Scott

Weining - August 3

12.2 Data-type-generic programming
12.2.1 Generic data-type representations

Omar - August 3

12.2.2 Example: Generating SQL queries

Omar - August 3

12.3 Template Haskell and quasiquotes
12.3.1 A tutorial on Template Haskell
(1st half - pp 410-415)

Jens - August 17

12.3.1 (2nd half - starting with Generating Declarations)

Jens - August 17

12.3.2 Example: Generating remote function calls (1st half - pp 421-426)

Omar - August 17

12.3.2 (2nd half - starting with Value Passing and Networking)

Omar - August 17

 

Chapter 11
Type system advances

June 30, 2022
July 13, 2022
July 20, 2022
July 27, 2022

Presenter

Chapter 11
Type system advances

June 30, 2022
July 13, 2022
July 20, 2022
July 27, 2022

Presenter

11.1 Haskell types 101
11.1.1 Terms, types, and kinds

Casey - June 30

11.1.2 Delivering information with types

Casey - June 30

11.1.3 Type operators

Casey - July 13

11.2 Data kinds and type-level literals
11.2.1 Promoting types to kinds and values to types
11.2.2 Type-level literals

Sergey - July 13

11.3 Computations over types with type families
11.3.1 Open and closed type synonym families
11.3.2 Example: Avoid character escaping in GHCi

Jens - July 13

11.3.3 Data families
11.3.4 Associated families

Weining - July 13

11.4 Generalized algebraic data types (motivation)

Casey - July 13

11.3.2 Example: Avoid character escaping in GHCi

Jens - July 20

11.4.1 Example: Representing dynamically typed values with GADTs
11.4.2 Example: Representing arithmetic expressions with GADTs

Casey - July 20

11.5.1 Arbitrary-rank polymorphism
11.5.2 Stateful Computations in the ST Monad

Omar - July 20
July 27

11.6 Advice on dealing with type errors

Sergey - July 27

 

Chapter 10
Benchmarking and profiling

June 22, 2022

Presenter

Chapter 10
Benchmarking and profiling

June 22, 2022

Presenter

10.1 Benchmarking functions with criterion
10.1.1 Benchmarking implementations of a simple function

Sergey

10.1.2 Benchmarking an IPv4 filtering application

Antonio

10.2 Profiling execution time and memory usage
10.2.1 Simulating iplookup usage in the real world
10.2.2 Analyzing execution time and memory allocation
10.2.3 Analyzing memory usage

Jens

10.3 Tuning performance of the IPv4 filtering application
10.3.1 Choosing the right data structure
10.3.2 Squeezing parseIP performance

Weining

 

Chapter 9
Haskell data and code at run time

June 1, 2022
June 8, 2022
June 22, 2022

Presenter

Chapter 9
Haskell data and code at run time

June 1, 2022
June 8, 2022
June 22, 2022

Presenter

9.1 A mental model for Haskell memory usage at run time
9.1.1 General memory structure and closures

Casey - June 1

9.1.2 Primitive unboxed data types

Casey - June 8

9.1.3 Representing data and code in memory with closures

Antonio - June 8

9.1.4 A detour: Lifted types and the concept of strictness

Antonio - June 8

9.2 Control over evaluation and memory usage
9.2.1 Controlling strictness and laziness

Weining - June 8

9.2.2 Defining data types with unboxed values

Casey - June 22

9.3 Exploring compiler optimizations by example
9.3.1 Optimizing code manually

Jens - June 22

9.3.2 Looking at GHC Core

Jens - June 22

 

Chapter 8
Writing Tests

May 25, 2022
June 1, 2022

Presenter

Chapter 8
Writing Tests

May 25, 2022
June 1, 2022

Presenter

8.1 Setting a scene: IPv4 Filtering application

Casey

8.2 Testing the IPv4 filtering application

8.2.1 Overview of approaches to testing
8.2.2 Testing Cabal projects with tasty

Casey

8.2.3 Specifications writing and checking with Hspec

Sergey

8.2.4 Property-based testing with Hedgehog

Weining - May 25 / June 1

8.2.5 Golden tests with tasty-golden

Jens - June 1

8.3 Other approaches to testing
8.3.1 Testing functions a la the REPL with doctest

8.3.2 Lightweight verification with LiquidHaskell

8.3.3 Code quality with hlint

Jens - June 1

Chapter 7
Error handling and logging

May 4, 2022
May 18, 2022

Presenter

Chapter 7
Error handling and logging

May 4, 2022
May 18, 2022

Presenter

7.1 Overview of error-handling mechanisms in Haskell

Weining

7.2 Programmable exceptions in monad stacks

Jens

7.3 GHC runtime exceptions
7.3.1 An idea of extensible exceptions
7.3.2 Throwing exceptions

Sergey - May 18

7.3.3 Catching exceptions

Casey - May 18

7.4 Example: Accessing web APIs and GHC exceptions
7.4.1 Application components

Antonio- May 18

7.4.2 Exception-handling strategies

Jens - May 18

7.5 Logging

Weining - May 18

 

Homework for April 27:

question 1 - “Do you see which (<$>) is applied in this implementation?" (p. 194, below implementation of instance Applicative m)

question 2 - explain the case Just v on the top of p. 195
(I see it now - Casey)

Chapter 6
Structuring programs with monad transformers

April 13, 2022
April 20, 2022
April 27, 2022

Presenter

Chapter 6
Structuring programs with monad transformers

April 13, 2022
April 20, 2022
April 27, 2022

Presenter

Problem of combining monads
6.1.1 Evaluating expressions in reverse Polish notation

Casey

6.1.2 Introducing monad transformers and monad stacks

Sergey

IO-based monad transformer stacks

6.2.1 Describing a monad stack

Jens

6.2.2 Exploiting monad stack functionality

Weining

6.2.3 Running an application
6.2.4 Can we do it without RWST?

Jens - April 20

What is a monad transformer?
6.3.1 Step 0: Defining a type for a transformer
6.3.2 Step 1: Turning a monad stack into a monad

Jens - April 20

6.3.3 Step 2: Implementing the full monad stack functionality

Weining - April 27

6.3.4 Step 3: Supplying additional functionality
6.3.5 Using a transformer

Sergey - April 27

Monad transformers in the Haskell libraries
6.4.1 Identity is where it all starts
6.4.2 An overview of the most common monad transformers

Casey - April 27

 

Chapter 5
Monads as practical functionality providers

March 16, 2022
March 23, 2022
April 6, 2022

Presenter

Chapter 5
Monads as practical functionality providers

March 16, 2022
March 23, 2022
April 6, 2022

Presenter

Basic monads in use: Maybe, Reader, Writer
5.1.1 Maybe monad as a line server

Sergey

5.1.2 Carrying configuration all over the program with Reader

Casey

5.1.3 Writing logs via Writer

SQL

GCD

 

Carl

Jens - April 6

Maintaining state via the State monad
5.2.1 Basic examples with the State monad

Weining - March 23

5.2.2 Parsing arithmetic expressions with State

Jens - March 23

5.2.3 RWS monad to rule them all: The game of dice

Antonio - April 6

Other approaches to mutability
5.3.1 Mutable references in the IO monad

Sergey - April 6

5.3.2 Mutable references in the ST monad

Casey - April 6

Chapter 4
Haskell development with modules, packages, and projects

March 2, 2022
March 9, 2022

Presenter

Chapter 4
Haskell development with modules, packages, and projects

March 2, 2022
March 9, 2022

Presenter

Organizing Haskell code with modules
4.1.1 Module structure, imports and exports, and module hierarchy

Carl

4.1.2 Custom preludes

Weining

4.1.3 Example: containers-mini

Sergey

Understanding Haskell packages

4.2.1 Packages at the GHC level

Jens

4.2.2 Cabal packages and Hackage

Jens - March 9, 2022

Tools for project development

Casey - March 9, 2022

Note:

In Section 3.2.5, in order to get the added dependencies to work, try running cabal with the option --allow-newer for the base package. Also update the versions to match those in hid-examples.cabal
cabal build --allow-newer=base

Chapter 3
Developing an application: Stock quotes

February 16, 2022
February 23, 2022

Presenter

Chapter 3
Developing an application: Stock quotes

February 16, 2022
February 23, 2022

Presenter

Setting the scene

Weining

Exploring design space

Jens

Implementation details
3.3.1 Describing data
3.3.2 Plotting charts

Casey

Implementation details
3.3.3 Preparing reports

Karthik - February 23

Implementation details
3.3.4 Implementing the user interface
3.3.5 Connecting parts

Sergey - February 23

More in-depth discussions on libraries



(optional) time library

 

(optional) blaze-html library

Casey - February 23

(optional) lucid library

 

(optional) colonnade library

 

(optional) Chart library

 

(optional) cassava library

Carl - February 23

(optional) optparse-applicative library

Sergey - February 23

(optional) cmdargs library

 

Chapter 2
Type classes

January 26, 2022
February 2, 2022

Presenter

Chapter 2
Type classes

January 26, 2022
February 2, 2022

Presenter

Manipulating a radar antenna with type classes
2.1.1-2.1.3

Sergey

Manipulating a radar antenna with type classes
2.1.4-2.1.5 (Show&Read and Testing)

Weining

Issues with numbers and text

Jens - February 2

Abstracting computations with type classes

Karthik - February 2

Chapter 1
Functions and types

January 17, 2022

Presenter

Chapter 1
Functions and types

January 17, 2022

Presenter

Solving problems in the GHCi REPL with functions

Casey

From GHCi and String to GHC and Text

Casey

Functional programs as sets of IO actions

Karthik

Embracing pure functions

Jens