VU 183.653 Methodical, industrial Software-Engineering using the Haskell functional programming language

2013-04-08

Last Time

Today

Garbage

factorial :: Integer -> Integer
factorial n = go (n `max` 0) 1
  where
    go 0 a = a
    go i a = go (i-1) $! (a*i)

Garbage Collection

Garbage Collection (cont.)

Garbage Collection (cont.)

Garbage Collection (cont.)

Heap Objects

Int on the Heap

Int on the Heap (cont.)

Char on the Heap

Bool on the Heap

(Bool,Bool,Int) on the Heap

String on the Heap

String on the Heap (cont.)

newtype on the Heap

UNPACK Pragma (cont.)

The strict ByteString type

The strict ByteString type (cont.)

The strict ByteString type (cont.)

The strict ByteString type (cont.)

Space Usage of strict ByteStrings

Summary of strict ByteStrings

Lazy ByteStrings

Text

Text (cont.)

data Text = Text {-# UNPACK #-} !Array    -- payload
                 {-# UNPACK #-} !Int      -- offset
                 {-# UNPACK #-} !Int      -- length
    
data Array = Array ByteArray#   -- UTF-16 representation

Integer on the Heap

Data.Vector

Data.Vector (cont.)

Data.Vector.Unboxed