On Tuesday, February 14, 2017 at 2:48:26 PM UTC, Rupert Smith wrote: > > On Tuesday, February 14, 2017 at 2:28:50 PM UTC, Rupert Smith wrote: >> >> Is there some way to avoid this, perhaps using extensible records? >> > > I was kind of hoping something like this might work, but it doesn't: > > type alias Positioned a = > { a | rect : Rectangle } > > type alias WithContent a = > { a | content : Maybe String } > > type State > = Hidden {} > | Aware (Positioned {}) > | Active (Positioned (WithContent {})) > | Inactive (Positioned (WithContent {})) >
Being able to pattern match like this is convenient: Aware { rect } -> Unfortunately there doesn't seem to be a way of doing deeper pattern matching: SomeState { someMaybe as Just value } Using the 'as' syntax. Some of the time this will mean using a nested case statement - although should mostly be avoided as only putting values you really need in each state should eliminate the Maybes. I have now turned the 'content' field into a String and dropped its Maybe. -- 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 elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.