I have a pop-over editor that can be in one of a variety of states. 
Originally my model was like this:

type alias Model =
    { 
    , state : State
    , content : Maybe String
    , rect : Maybe Rectangle
    }

type State
    = Hidden
    | Aware 
    | Active 
    | Inactive 

'rect' is only needed in the states where the editor is visible, to 
position it. 'content' only has a value once some content has been typed in 
by the user.

Then I changed it to be like this:

type alias Model =
    { state : State }

type State
    = Hidden
    | Aware Rectangle
    | Active Rectangle (Maybe String)
    | Inactive Rectangle (Maybe String)

Which seems better and I got rid of 1 Maybe. Every time I use 
Maybe.withDefault I feel strangely guilty...

When moving between states, I have to copy values from the previous State. 
Is there some way to avoid this, perhaps using extensible records? Or just 
the necessary price you pay for applying this kind of transformation? I 
should really take some time-out to watch the various tutorials on making 
illegal states unrepresentable to pick up some tips.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to