Tune in to the tools and techniques in the Elm ecosystem.
040: Phantom Builder Pattern
      
        September 27, 2021
      
      
        1:05:51
      
      
        
          63.25 MB
        
      
      
        Downloads: 0
      
    
    
      Phantom types (happens at compile time, not runtime)
Helps avoid things like adding centimeters and inches
Joël Quenneville's phantom types talk from Elm in the Spring A Number by Any Other Name
Extensible records
Builder pattern
elm-graphqlSelectionSetscope type variableBrian Hicks' builder pattern talk Robot Buttons from Mars
withfunctionsPhantom builder is a state machine for your types
elm-reviewRule API uses phantom builderPhantom types discourse post on time package Simon Herteby
Snapshot test in Elm review for expected error messages
Possible operations with phantom extensible builders
- Add a new field
 - Remove a field
 - Change the type of a field
 - Remove the previously existing phantom type and change it to an empty record (not extensible, just a hardcoded return type) i.e. Replace
 
What you can do with phantom builder
- Require something to be always called
 - Forbid something being called more than once
 - Cause other constraints dynamically after calling something
 - Make function calls mutually exclusive
 - Enable a function only if another one has been called