Skip to content

jfmengels/factory-example

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

Solution for the factory puzzle

The puzzle was described in the article Single out element using phantom types.

To test, run:

elm make src/Main.elm

The project does not compile on purpose, to show that something we wanted to be forbidden is impossible.

-- TYPE MISMATCH -------------------------------------------------- src/Main.elm

The 1st argument to `createGreenCarFactory` is not what I expect:

34|     Factory.createGreenCarFactory
35|>        (\_ ->
36|>            [ Factory.dieselCar
37|>            , Factory.electricCar
38|>            , Factory.hydrogenCar
39|>            ]

This argument is an anonymous function of type:

    data -> List (Factory.Car Factory.Polluting)

But `createGreenCarFactory` needs the 1st argument to be:

    data -> List (Factory.Car Factory.Green)

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages