Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Loader v m = Loader {
- loadMaybe :: ResourceKey -> m (Maybe v)
- data ResourceKey = ResourceKey {}
- type DatatypeName = String
- type ModuleName = String
- load :: forall r v m. (FromResource r, Typeable r, Typeable v, Monad m) => Loader v m -> m v
- data ResourceNotFound = ResourceNotFound TypeRep ResourceKey TypeRep
- class FromResource a where
- dataDirLoader :: MonadIO m => [FileExtension] -> DataDir -> Loader ByteString m
- type FileExtension = String
- type DataDir = FilePath -> IO FilePath
- dataDir :: FilePath -> DataDir
- extendDataDir :: DataDir -> FilePath -> DataDir
Resource loader.
Loader | |
|
Instances
Generic (Loader v m) Source # | |
Monad m => Semigroup (Loader v m) Source # | The left |
Monad m => Monoid (Loader v m) Source # | |
type Rep (Loader v m) Source # | |
Defined in Dep.Loader type Rep (Loader v m) = D1 ('MetaData "Loader" "Dep.Loader" "dep-t-value-0.1.0.0-9HathWkr8833kq2ESFmsQK" 'True) (C1 ('MetaCons "Loader" 'PrefixI 'True) (S1 ('MetaSel ('Just "loadMaybe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ResourceKey -> m (Maybe v))))) |
data ResourceKey Source #
Instances
Eq ResourceKey Source # | |
Defined in Dep.Loader (==) :: ResourceKey -> ResourceKey -> Bool # (/=) :: ResourceKey -> ResourceKey -> Bool # | |
Ord ResourceKey Source # | |
Defined in Dep.Loader compare :: ResourceKey -> ResourceKey -> Ordering # (<) :: ResourceKey -> ResourceKey -> Bool # (<=) :: ResourceKey -> ResourceKey -> Bool # (>) :: ResourceKey -> ResourceKey -> Bool # (>=) :: ResourceKey -> ResourceKey -> Bool # max :: ResourceKey -> ResourceKey -> ResourceKey # min :: ResourceKey -> ResourceKey -> ResourceKey # | |
Show ResourceKey Source # | |
Defined in Dep.Loader showsPrec :: Int -> ResourceKey -> ShowS # show :: ResourceKey -> String # showList :: [ResourceKey] -> ShowS # |
type DatatypeName = String Source #
type ModuleName = String Source #
load :: forall r v m. (FromResource r, Typeable r, Typeable v, Monad m) => Loader v m -> m v Source #
Throws ResourceNotFound
.
data ResourceNotFound Source #
Instances
Show ResourceNotFound Source # | |
Defined in Dep.Loader showsPrec :: Int -> ResourceNotFound -> ShowS # show :: ResourceNotFound -> String # showList :: [ResourceNotFound] -> ShowS # | |
Exception ResourceNotFound Source # | |
Defined in Dep.Loader |
Datatypes tied to resources.
class FromResource a where Source #
Class for datatypes tied to resources.
Derive it with DeriveAnyClass
. The datatype must have a GHC.Generics.Generic instance.
Nothing
resourceKey :: ResourceKey Source #
default resourceKey :: forall name mod p n nt x. (Generic a, Rep a ~ D1 ('MetaData name mod p nt) x, KnownSymbol name, KnownSymbol mod) => ResourceKey Source #
Loaders for resources in a directory.
dataDirLoader :: MonadIO m => [FileExtension] -> DataDir -> Loader ByteString m Source #
A dataDirLoader ["js", "json"] (dataDir "conf")
Loader
will, for a datatype Baz
defined
in module Foo.Bar
, look for the files conf/Foo/Bar/Baz.js
and conf/Foo/Bar/Baz.json
,
in that order.
type FileExtension = String Source #