{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PartialTypeSignatures #-} {-# 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" -- <.> response @Char @'[PlainText] <+> "about" pathSegment "me" -- <. response2 @Char @'[PlainText] content = \case -- In -> Out Index{} -> return "INDEX" About -> return "ABOUT" -- c0 = compile CompilerEnv{} router content address_IndexMe :: Address address_IndexMe = address router Index address_AboutMe :: Address address_AboutMe = address router About