Skip to content

Latest commit

 

History

History
51 lines (45 loc) · 1.75 KB

Plan

File metadata and controls

51 lines (45 loc) · 1.75 KB

-*- Org -*-

Learning outcomes

DSL: design embedded domain specific languages

DSL.Implement: implement EDSLs in Haskell (as combinator libraries)

Types: read, understand and extend Haskell programs which use

advanced type system features Types.HOT: functors, monads and monad transformers Types.Class: type classes, newtypes, deriving, …

Lecture overview

Monad transformers

file:MonadT_API_summary.hs file:mtl/Control/Monad/Reader.hs Higher-order type + corresponding type class:

ReaderT r m a + MonadReader r m

StateT s m a + MonadState s m

ErrorT e m a + MonadError e m

WriterT w m a + MonadWriter w m

Running example: “Growing a language”

Starting from a trivial expression language with only numbers and addition (file:src/Interpreter0.hs) adding features one by one:

Variables and let-binding

file:src/Interpreter1.hs

References (pointers to a heap) and state

file:src/Interpreter2.hs

Exceptions and error-handlers

file:src/Interpreter3.hs

Base language: file:src/Interpreter0.hs

Variables and let-binding: file:src/Interpreter1.hs

(In 2015 this was the start of lecture 6.)

file:MonadT_API_summary.hs file:src/Test.hs

For the curious, the full source code of the monad transformer library can be downloaded and inspected as follows:

cabal unpack mtl file:mtl-2.2.1/Control/Monad/State/Lazy.hs

References and state: file:src/Interpreter2.hs

Exceptions and error-handlers: file:src/Interpreter3.hs

Preparation of “live-coding” environment

rm -r live

rsync –recursive ./ live/

rsync –recursive before/ live/