Making Impossible States Impossible

121 views
Skip to first unread message

Ed Ilyin

unread,
Sep 30, 2016, 12:08:29 PM9/30/16
to Elm Discuss
I have watched a great talk "Making Impossible States Impossible" by Richard Feldman.

But I can't figure out how to make impossible wrong modes of pages.

Stright forward approach looks like following:

```elm
type ListView = ListView
type DetailsView = DetailsView
type PolymerElement = PolymerElement
type ElmElement = ElmElement

type Page
  = BuildingList ListView PolymerElement
  | BuildingDetails DetailsView PolymerElement
  | BulbList ListView PolymerElement
  ...
  | HorseDetails DetailsView ElmElement
```

But then I can't write a pattern to match only DetailViews to add the back button to the view.
Or match only PolymerElements to import Polymer element for specific page.

Is it possible to achieve without writing case...of of all pages multiple times in code?

Peter Damoc

unread,
Sep 30, 2016, 12:30:53 PM9/30/16
to Elm Discuss
It looks like you are duplicating knowledge. If your BuildingList can only be connected to a ListView, adding that in the type is redundant. Same with Elements.

Think in terms of: what is the minimal information that I can get in the view in order to be able to render what I need to render and model only that.

If you know that BuildingList uses a listView and Polymer, then only use BuildingList. It is sufficient.


  

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
There is NO FATE, we are the creators.
blog: http://damoc.ro/
Reply all
Reply to author
Forward
0 new messages