{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# OPTIONS_GHC -Wno-missing-signatures #-} module Examples.Ex01 where import Network.URI.Slug as URI import Relude import Symantic.Classes (ProductFunctor (..), SumFunctor (..), adt) import Webc -- | A convenient data-type to avoid using 'Either's and Tuples. data Site = Index | About | Contact URI.Slug deriving (Eq, Show, Generic) {- | Polymorphic expression describing the website, to be instantiated to the various interpreters. NoMonomorphismRestriction is used to avoid specifying manually the inferred symantic classes. -} site = -- site :: IsoFunctor repr => SumFunctor repr => Slugable repr => repr Site -- Using Generic, 'adt' derives (Iso{a2b, b2a} <%>) -- from the 'Site' algebraic data-type. adt @Site $ literalSlug "index.html" <+> literalSlug "about.html" <+> captureSlug "user" <. literalSlug "contact.html"