From 8e3a7bf1cb83bbb6e3dcd54308eefa52a29cd679 Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 3 Jun 2016 20:27:16 +0200 Subject: Migrate to elm 0.17 --- src/client/elm/Page.elm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/client/elm/Page.elm (limited to 'src/client/elm/Page.elm') diff --git a/src/client/elm/Page.elm b/src/client/elm/Page.elm new file mode 100644 index 0000000..7cfbbc7 --- /dev/null +++ b/src/client/elm/Page.elm @@ -0,0 +1,32 @@ +module Page exposing + ( Page(..) + , toHash + , fromHash + ) + +import Navigation +import UrlParser exposing (..) +import String + +type Page = + Home + | Income + | Statistics + +toHash : Page -> String +toHash page = + case page of + Home -> "#" + Income -> "#income" + Statistics -> "#statistics" + +fromHash : Navigation.Location -> Result String Page +fromHash location = UrlParser.parse identity pageParser (String.dropLeft 1 location.hash) + +pageParser : Parser (Page -> a) a +pageParser = + oneOf + [ format Home (s "") + , format Income (s "income") + , format Statistics (s "statistics") + ] -- cgit v1.2.3