Last active
September 21, 2016 17:07
-
-
Save MarkyMarkMcDonald/7393b19b339a0394edd090ee61d547ad to your computer and use it in GitHub Desktop.
Exposing list of attributes to be iterated over by validation check. See https://github.com/MarkyMarkMcDonald/elm-architecture-tutorial/commit/ede42b04414df3365dd6d7673dca9b6a6a32ab61?w=1 for full context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Shape = Diamond | Oval | Squiggle | |
type Number = One | Two | Three | |
type Color = Red | Green | Blue | |
type Attribute = Color | Shape | Number | |
type alias Model = { | |
shape: Shape, | |
number: Number, | |
color: Color | |
} | |
attributes : List (Model -> Attribute) | |
attributes = [.color, .shape, .number] | |
Working final solution:
type alias Model =
{ shape: Shape
, number: Number
, color: Color
}
attributes : List (Model -> Attribute)
attributes = [\x -> ColorAtt x.color, \x -> ShapeAtt x.shape, \x -> NumberAtt x.number]
type Attribute
= ColorAtt Color
| ShapeAtt Shape
| NumberAtt Number
type Color = Red | Green | Blue
type Shape = Diamond | Oval | Squiggle
type Number = One | Two | Three
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We get this compiler error: