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") ]