Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phantom types #49

Open
Neurrone opened this issue Mar 25, 2017 · 1 comment
Open

Phantom types #49

Neurrone opened this issue Mar 25, 2017 · 1 comment

Comments

@Neurrone
Copy link

Neurrone commented Mar 25, 2017

Outline:

  • What are phantom types, and how they can be used?
  • Why use phantom types?

Slides

@Neurrone
Copy link
Author

Neurrone commented Mar 26, 2017

PUMA outline:

  1. Audience: fellow CS3281/2 students
  2. Objective: To encourage use of phantom types
  3. Topic: Prevent bugs at compile-time with phantom types
  4. PUNCH: Show real scenario that could have been prevented using phantom types
  5. WIIFY: Learn a technique that you can immediately use to write code with less bugs.
  6. Promise:
    • WHAT are phantom types?
    • Why are phantom types worth using?
    • When to/not to use phantom types?
  7. Content:
    • WHAT are phantom types?
      • Explained through an example
      • Key point: phantom types is a technique that cleverly uses type parameters to augment types with extra info
    • WHY use phantom types?
      • Encode invariants into the type system so we can use the compiler to find bugs
      • Easy
      • No runtime costs
      • Support: demonstrate with examples
      • Key point: Using phantom types is worth doing because it lets you catch some bugs at compile-time
    • When to/not to use?
  8. Key points / summary statement / elevator pitch
    • Phantom types is a technique where unused type parameters in types can be used to augment the type with extra info.
    • Distinguish types that are otherwise identical at compile-time, e.g if the type has multiple states - sanitized vs unsanitized, units of measurement
    • Use only when pros > cons (like design patterns)
    • Easy and worth doing,
  9. Call to action: Let’s start using phantom types!

Do: start using phantom types
Believe: using phantom types is easy and worthwhile
Know: what are phantom types, why and when they are useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants