Skip to content

devalot/hstypes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction to Haskell Types

Topics and Goals

  1. Introduction to algebraic data types
  2. Record syntax, fields, and functions
  3. Product types (constructors with more than one argument)
  4. Sum types (tagged unions)
  5. Polymorphic types (product and sum)
  6. Exploiting the type system

Introduction to Algebraic Data Types

  • The data keyword
  • Type constructors vs. data constructors
  • Type constructors are used in type signatures
  • Data constructors are used in patterns and code

Record Syntax, Fields, and Functions

  • Records look sort of like a C struct
  • Fields turn into functions
  • Record update syntax (sucks)

Product Types

  • Data constructors that have more than one type
  • Records with more than one field are product types
  • Pattern matching to get the fields

Sum Types

  • Multiple data constructors
  • Canonical example: Bool = False | True
  • Compared to a C enum
  • Pattern matching on all data constructors

Polymorphic Types

  • The type constructor uses type variables
  • The Maybe and Either types
  • Binary tree example

Exploiting the Type System

  • Preventing SQL injection attacks
  • Software Transactional Memory

About

Introduction to Haskell Types (Presentation)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published