restyler-0.2.0.0
Safe HaskellNone
LanguageHaskell2010

Restyler.Config

Description

Handling of .restyled.yaml content and behavior driven there-by

Implementation note: This is a playground. I'm doing lots of HKD stuff here that I would not normally subject my collaborators to.

  1. We only do this stuff here, and
  2. It should stay encapsulated away from the rest of the system

References:

Synopsis

Documentation

data ConfigF f Source #

A polymorphic representation of Config

  1. The f parameter can dictate if attributes are required (Identity) or optional (Maybe), or optional with override semantics (Last)
  2. Any list keys use SketchyList so users can type a single scalar element or a list of many elements.
  3. The Restylers attribute is a (sketchy) list of ConfigRestyler, which is a function to apply to the later-fetched list of all Restylers.

See the various resolve functions for how to get a real Config out of this beast.

emptyConfig :: ConfigF Maybe Source #

An empty ConfigF of all Nothings

N.B. the choice of getAlt is somewhat arbitrary. We just need a Maybe wrapper f a where getX mempty is Nothing, but without a Monoid a constraint.

data Config Source #

Fully resolved configuration

This is what we work with throughout the system.

Instances

Instances details
Eq Config Source # 
Instance details

Defined in Restyler.Config

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

Show Config Source # 
Instance details

Defined in Restyler.Config

Generic Config Source # 
Instance details

Defined in Restyler.Config

Associated Types

type Rep Config :: Type -> Type #

Methods

from :: Config -> Rep Config x #

to :: Rep Config x -> Config #

ToJSON Config Source # 
Instance details

Defined in Restyler.Config

type Rep Config Source # 
Instance details

Defined in Restyler.Config

type Rep Config = D1 ('MetaData "Config" "Restyler.Config" "restyler-0.2.0.0-6CU09At3uqu54PYk8pZPUE" 'False) (C1 ('MetaCons "Config" 'PrefixI 'True) (((S1 ('MetaSel ('Just "cEnabled") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "cExclude") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Glob]) :*: S1 ('MetaSel ('Just "cChangedPaths") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChangedPathsConfig))) :*: (S1 ('MetaSel ('Just "cAuto") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "cRemoteFiles") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [RemoteFile]) :*: S1 ('MetaSel ('Just "cPullRequests") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))) :*: ((S1 ('MetaSel ('Just "cComments") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "cStatuses") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Statuses) :*: S1 ('MetaSel ('Just "cRequestReview") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RequestReviewConfig))) :*: (S1 ('MetaSel ('Just "cLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set (Name IssueLabel))) :*: (S1 ('MetaSel ('Just "cIgnoreLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set (Name IssueLabel))) :*: S1 ('MetaSel ('Just "cRestylers") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Restyler]))))))

configPullRequestReviewer :: PullRequest -> Config -> Maybe (Name User) Source #

If so configured, return the User from whom to request review

loadConfig :: (HasLogFunc env, HasSystem env, HasDownloadFile env) => RIO env Config Source #

Load a fully-inflated Config

Read any .restyled.yaml, fill it out from defaults, grab the versioned set of restylers data, and apply the configured choices and overrides.

loadConfigF :: HasSystem env => [ConfigSource] -> RIO env (ConfigF Identity) Source #

Load configuration if present and apply defaults

Returns ConfigF Identity because defaulting has populated all fields.

May throw any ConfigError. May through raw ParseExceptions if there is a programmer error in our static default configuration YAML.

decodeThrow' :: (MonadUnliftIO m, MonadThrow m, FromJSON a) => ByteString -> m a Source #

decodeThrow, but wrapping YAML parse errors to ConfigError

resolveRestylers :: ConfigF Identity -> [Restyler] -> RIO env Config Source #

Populate cRestylers using the versioned restylers data

May throw ConfigErrorInvalidRestylers.