servant-zeppelin-server-0.1.0.1: Server library for servant-zeppelin combinators.

Safe HaskellNone
LanguageHaskell2010

Servant.Zeppelin.Server

Contents

Synopsis

Necessary for using SideLoad deps.

class Inflatable m base where #

Inflatable represents a type b which can be expanded inside of a context m.

type PGMonad = ReaderT Connection (ExceptT QueryError IO)

instance Inflatable PGMonad PersonId where
  type Full PGMonad PersonId = Person
  inflator = getPersonById

Minimal complete definition

inflator

Associated Types

type Full (m :: * -> *) base :: * #

Methods

inflator :: base -> m (Full m base) #

Instances

Inflatable Identity base

Anything can be expanded into itself in the trivial context.

Associated Types

type Full (Identity :: * -> *) base :: * #

Methods

inflator :: base -> Identity (Full Identity base) #

data DependencyList a b c :: (* -> *) -> [*] -> [*] -> * where #

DependencyList m bs fs is a type representing a heterogeneous list parameterized by bs , which can be transformed into a hetergeneous list of type fs in the context provided by m.

Constructors

NilDeps :: DependencyList a ([] *) ([] *) 
(:&:) :: DependencyList a ((:) * b1 bs) ((:) * f fs) infixr 5 

Instances

AllSatisfy * bs (Eq' *) => Eq (DependencyList m bs fs) 

Methods

(==) :: DependencyList m bs fs -> DependencyList m bs fs -> Bool #

(/=) :: DependencyList m bs fs -> DependencyList m bs fs -> Bool #

AllSatisfy * bs (Show' *) => Show (DependencyList m bs fs) 

Methods

showsPrec :: Int -> DependencyList m bs fs -> ShowS #

show :: DependencyList m bs fs -> String #

showList :: [DependencyList m bs fs] -> ShowS #

class AllSatisfy * bs (Inflatable' * (* -> *) m) => HasDependencies m a bs | a -> bs, bs -> m where #

Indicate that a type has dependencies, and supply the uninflated values.

data Album =
  Album { albumId     :: AlbumId
        , albumArtist :: PersonId
        , albumPhotos :: [PhotoId]
        , albumTitle  :: Text
        }

instance HasDependencies PGMonad Album '[Person, [PhotoId]] where
  getDependencies album = albumArtist album :&: albumPhotos album :&: NilDeps

Minimal complete definition

getDependencies

Methods

getDependencies :: a -> DependencyList m bs (Map * * (Full' * (* -> *) m) bs) #

Type family for JSON object keys.

type family NamedDependency a :: Symbol #

Labels for the objects created in the dependency mapping. Necessary for JSON instances.

type instance NamedDependency Person = "person"
type instance NamedDependency [Photo] = "photos"

Servant combinator

data SideLoad fs :: [*] -> * #

Combinator to indicate the availablity of side loaded data.

"albums" :> Get '[JSON] Album :> SideLoad '[Person, [Photo]]

Instances

type ServerT * ((:>) * * (Verb * k1 method status ctypes a) (SideLoad fs)) m # 
type ServerT * ((:>) * * (Verb * k1 method status ctypes a) (SideLoad fs)) m = m a