SO: What's the motivation to use a phantom type?

Posted on 2015-01-31 by Oleg Grenrus

The question

Don Stewart's Haskell in the Large's presentation mentioned Phantom Types:

data Ratio n = Ratio Double
1.234 :: Ratio D3

data Ask ccy = Ask Double
Ask 1.5123 :: Ask GBP

What's the motivation to use a phantom type?

The answer

To answer the "what's the motivation to use a phantom type". There is two points:

  • to make invalid states inrepresentable
  • carry some of the information on the type level

Read rest the rest on StackOverflow

Site proudly generated by Hakyll