{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# OPTIONS_GHC -Wno-missing-signatures #-} module Examples.Ex02 where import Literate.Web hiding (index) import Relude -- | A convenient data-type to avoid using Eithers-of-Tuples or Tuples-of-Functions. data Route = Index | About deriving (Eq, Show, Generic) -- | Using Generic, 'dataType' derives -- from the 'Route' algebraic data-type -- a function transforming Eithers-of-Tuples into a 'Route'. router = dataType @Route $ pathSegment "index" <+> "about" pathSegment "me" content = \case Index -> return "INDEX" About -> return "ABOUT"