{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# OPTIONS_GHC -Wno-missing-signatures #-} module Examples.Ex01 where import Relude import Symantic.Classes (SumFunctor (..), adt) import Webc -- | A convenient data-type to avoid using 'Either's and Tuples. data Site = Index | About -- Contact URI.Slug -- Post [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" -- <+> "post" many0 (captureSlug "dir")